Pavithra Rajamohan · Oct 13

Method for retreiving embedded PDF file from JSON

Hello all,

I receive an embedded PDF link as part of a JSON message. The %Get method is currently used to extract the data items from the JSON message, however we have come across a problem when trying to extract a data item which is an embedded PDF file as the string is too long. Does anyone have any suggestions as to what would be the appropriate method to use to extract this particular data item?


1 0 3 144
Log in or sign up to continue

%Get() accepts a type parameter -- you can specify a type of stream and it will return a stream object, which is not limited by the max size of strings.

Thanks Marc, unfortunately we are using an older version of Healthshare (2017) and the %Get method doesnt include the type parameter and only has the key. The method listed in the system is as follows:

Method %Get(key) As %CacheString
    try {
set ans = $zu(210,10, .key)
    catch do $$$APPERROR1($$$LASTERROR) }

Are there any other methods that can be used?


Would this section of documentation help with your situation?

(I'm aware this is from the latest documentation online, but I did confirm that this section also exists in my HealthShare 2017.2 version as well.)

That section appears to basically describe how to save the JSON to a temporary file on the filesystem, then re-open the file as an Object and access the key successfully without hitting <MAXSTRING>. Yes, I'm aware that does cause extra storage I/O, so for busy servers this could have a negative impact on I/O performance.

It looks like they also offer a possible solution changing the JSON entity to a %Stream.GlobalCharacter which can handle strings much larger than <MAXSTRING> which may help with not adding nearly so much storage I/O as the solution in the previous paragraph.

Hope this helps!