Mike Yackanich · Jan 11, 2021

How to use HS.JSON.Path

Has anyone used the ##class(HS.JSON.Path).%Evaluate() classmethod interrogate JSON and return a specific object value? I need to extract the MessageHeader.destination.endpoint value from a FHIR bundle and can't seem to get that XPath-like method to work.

2 0 2 60
Log in or sign up to continue


HS.JSON.Path is intended for use with dynamic objects. With a dynamic object it'd look like (for example):

SAMPLE>set obj = {"destination":{"endpoint":"foo"}}
SAMPLE>w ##class(HS.JSON.Path).%Evaluate(obj,"$.destination.endpoint").%Get(0)

Also, this should probably be a question rather than an announcement.

Thanks! Yes indeed - a question vs announcement - not sure how that got changed (?). But thanks - I think that's my issue - I have a stream vs an object as 1st parameter.

Thanks again!