9 Followers · 445 Posts

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write.

Question prashanth ponugoti · Feb 3, 2022

Hi Community,

I have json equivalent persistent object in pjsonObj variable. Final JSON example below.

{
     "Document": {
                    "FileExtension": "pdf",
                    "FileContent": "JVBERi0xLjUNCiW1tbW1DQo...(very large bsae64 string)"
                }
}

Here FileContent field in json will contain converted base64 string of very large pdf(10pages). I need to submit this json as a payload to REST endpoint.

below code is working fine. 

set tSC=##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(.newobj,pjsonObj,,,1,"aelqtw")
$$$LOGINFO("json"_newobj.Read())

1
0 504
Article Robert Cemper · Jan 24, 2022 1m read

I have created a package that offers a utility to load a Global into JSON object and reverse     
to create a Global from this type of JSON object. Academic refers to the structure created.
Each logical node of the Global is presented separately with all its descendants.
Even if they don't contain any stored data.

1
0 390
Question Martin Staudigel · Jan 24, 2022

Hello Community,

to return data from the OnPage() method of a %CSP.Page I used to simply write out the value of a %DynamicArray e.g. via

write tResponse.%ToJSON()

and return $$$OK afterwards.

Large objects bigger than 4MB result in an exception when trying to create return values using this way. What is best practice for returning values as JSON, especially if values exceeding the capcity of the %String class are to be expected? I saw that it is possible to write data to a file with e.g.:

set tmp = tResponse.%ToJSON("/opt/home/tmp/test_stream.txt")

3
0 395
Question Mike Yackanich · Jan 18, 2022

Hi all,

I am testing asynchronous Bulk Data retrieve with a large EHR vendor. When I retrieve the bulk data, they are returning ndjson (CONTENT-TYPE of "application/fhir+ndjson; charset=utf-8"). If I attempt to process that content using JSON functions - I get

ERROR #5035: General exception Name 'Parsing error' Code '3' Data ''

For example, the following generates the error

s objArray={}.%FromJSON(quickStreamOut)

The error makes sense in that ndjson is not a valid json format (I assume at least).

1
0 584
Article Chris Stewart · Apr 18, 2017 3m read

or "So you just got yelled at by your boss, for sending him an unformatted Hello World webpage"

Our previous lesson ended with us serving a Message value obtained from a Caché REST service to the client, using Angular as a runtime.  While there is a lot of moving parts involved in this process, the page is not especially exciting at the moment.  Before we can start adding new features, we should take a step back and review our tools.

1
1 2694
Question Justin Richter · Jan 3, 2022

So I've been reviewing a lot of questions posted in the InterSystems community regarding NULL properties in JSON. I've also been reviewing the JSON documentation. None of these things have been able to help me so far.

1. We don't seem to have the %JSON.Adaptor class available for us to use in our system.

2. I'm not really confident enough to create JSON Type classes or backporting code, etc.

2
0 839
Question prashanth ponugoti · Nov 24, 2021

Hi All,

I am working in Heath Share Heath Connect Integration.

I have a requirement to change SOAP call to REST call in integration. For SOAP call already payload is ready in XML string. and Working fine.

Now I need to make REST API call instead of existing SOAP call.

I have created REST Business Operation and ready to Call it from Business Process.

Here I should not change any Transformation in Business Process , only change  in Operation invocation

Only change is existing SOAP Operation expecting XML String , new REST Operation is expecting JSON.

5
0 1012
Question Peter Hodgkin · Oct 26, 2021

I have an issue where a Windows Reserved word, in my case CON, is causing an error when used as part of a JSON Get operation.  In this case CON is the user identifier (the full identifier is CON.SURNAME) of a person and I am trying to read the employee record using a web service provided by the payroll system.

Is there a way I can get around this, some sort of encoding that would enable the inclusion of this identifier.  I can't just change the identifier has it is used extensively across systems.

3
0 256
Question Token Ibragimov · Oct 13, 2021

hello!

i have object bellow

Set object = ##class(%ZEN.proxyObject).%New()
set object.city = "New York"
set object.Target = "TEST" 
set object.Details = "TEST"
set object.RefCode = "123"
set object.Reason = "123TTTT"

I want to get string from json object. 

Could you help please ?

8
0 1175
Article Timothy Leavitt · Jun 4, 2020 3m read

Over the past year or so, my team (Application Services at InterSystems - tasked with building and maintaining many of our internal applications, and providing tools and best practices for other departmental applications) has embarked on a journey toward building Angular/REST-based user interfaces to existing applications originally built using CSP and/or Zen. This has presented an interesting challenge that may be familiar to many of you - building out new REST APIs to existing data models and business logic.

34
7 1823
Question Lucas Macori · Jun 11, 2021

Hello everyone,

I'm creating a REST API with InterSystems Ensemble.

I already have a POST route that parses JSON content into an object defined in a class.

To parse the JSON content, I'm using the JSONStreamToObject method in the Ens.Util.JSON class

Here is how I use it:

Set tSC = ..JSONStreamToObject(%request.Content, .tObject, "MyClass", 1)

 

While the route works and does what it should, in theory.

I noticed that when passing empty string or null values inside the JSON content, the values do not appear at all in the object's instance.

1
0 1828
Article Chris Stewart · Apr 21, 2017 3m read

So, one day you're working away at WidgetsDirect, the leading supplier of widget and widget accessories, when your boss asks you to develop the new customer facing portal to allow the client base to access the next generation of Widgets..... and he wants you to use Angular 1.x to read into the department's Caché server.   

There's only one problem:  You've never used Angular, and don't know how to make it talk to Caché.

This guide is going to walk through the process of setting up a full Angular stack which communicates with a Caché backend using JSON over REST.  

11
5 7030
Question Flávio Lúcio Naves Júnior · May 20, 2021

Hello everyone,

I created a Class with this 3 properties

Class TestDynamic Extends (%RegisteredObject, %XML.Adaptor)
{

Property number As %xsd.string;

Property exam As %xsd.string;

Property result As list Of %DynamicObject;

}

I'm adding objects to list normally

set objTest=##class(TestDynamic).%New()
set objDynamic={"field":"value"}
do objTest.result.Insert(objDynamic)

But when i use this method to convert to JSON

##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(objTest,,,"aeoqtw")

It doesn't show the items from %DynamicObject just show this:

7
0 568
Question Sehinde Raji · Jun 8, 2021

Hi all, I am new to IS Objectscript and I would appreciate some assistance regarding this. 

I am trying to find out how to count the number of elements within a dynamic abstract object and I am having some trouble using the size method.

Here is the code below:

The key value pairs are originally in JSON and I would have converted it in to an object for use.

7
0 419
Question David Hockenbroch · May 18, 2021

 I'm trying to set up VS Code for ObjectScript using the instructions found here. I've got both Cache 2018.1.2.309.0 and IRIS 2020.1.0.215.0. When I try to connect to either one of them the connection fails, and I get a notification in the bottom right corner that says "Unexpected token < in JSON at position 0". I've checked the JSON settings file that VS Code uses, and they're fine and formatted properly. All of the settings I've entered are correct. I suspect that there's a response coming back from the server that VS Code is expecting to be JSON, but isn't. It pops up any time I click on

20
0 6159
Question Raghu Yadati · May 20, 2021

pResponse.%JSONImport(tHttpResponse.Data)  failing when we have mulitple (array) json objects in response.

set patientSearchList = ##class(msg..patient.PatientSearchList).%New()

rListObj={} 
rListObj.%Set(ListViewName,[].%FromJSON(tHttpResponse.Data))

 do pResponse.%JSONImport(rListObj)

What's the better way to handle multiple json objects coming in response.

2
0 617
Article Dmitry Maslennikov · Oct 6, 2020 6m read

Let's imagine if you would like to write some real web application, for instance, some simple clone of medium.com. Such sort of application can be written using any different language on the backend side, or with any framework on the frontend side. So many ways to do the same application, and you can look at this project. Which offers a bunch of frontends and backends realizations for exactly the same application. And you can easily mix them, any chosen frontend should work with any backend.

Let me introduce the same application realization for InterSystems IRIS on a backend side.

3
1 1061
Question Utsavi Gajjar · May 10, 2021

Hello,

I am trying to find out if it is possible to decode the Azure access token in IRIS. Has anyone ever tried this before? I need to decode the token to extract the "Scope" details in order to verify the scope to make sure client is permitted to do the request they have done.

If you could point me to any information, that'd be great. 

Thank you.

Utsavi

7
1 902
Question Sabit Issakhan · Apr 28, 2021
Hello! I have a question how to parse Library.ListOfObjects to JSON

I send post data like this from client using rest and want parse "templates", after save "codeForm","codeName" in database

{
    "whoIs": "",
    "templates": [{
            "codeForm": "FORM_FIOGROUP",
            "codeName": "operationDate",
            "orderNumber": "1",
            "codeFormat": "YYYY-MM-DD",
            "header": "DATE",
            "dbfFormatType": "Date",
            "dbfFormatLength": "8",
            "valueFrom": "Payment"
        }, {
            "codeForm": "FORM_FIOGROUP",
4
0 699
Question Jerry Petrole · Mar 22, 2021

Hello

I am creating an import tool to convert a client's JSON data into IRIS classes.   The sample file is over half a gig.   I am copying the data into an instance of %Stream.FileCharacter;.    My first few attempts worked fine.   However I started getting an error thrown when I try to create a DynamicAbstractObject using the  %FromJSON method.     See the code below.   The error code given is not in the documentation, at least not the doc that I was searching.   

       "READ error while reading input stream, Line 5121169 Offset 23, error code 10"

Can anyone shed light on this error code?

3
0 410
Question Stuart Byrne · Mar 14, 2021

I had a challenge recently where I was asked to parse and iterate JSON to find a patient that has a forename = "Bill" and try to make the function that iterates through the code re-usable.

Being working in Healthcare there isn't much experience or demand for parsing JSON, as most of my work is HL7.

I took this on using the documentation and worked out a way to parse the JSON (see posts below for code and source data).

I've worked out how to iterate through the fields and repeating elements, however I'm having an issue quitting out upon finding a patient with the forename Bill.

6
0 511
Question Luiz Henrique Carvalho Martarelli · Mar 5, 2021

Hi!

I am making a request to an API and JSON is coming as follows:
SET %httprequest = ##class(%Net.HttpRequest).%New()
DO %httprequest.Get(URL)
SET %responseBody = %httprequest.HttpResponse.Data.Read()
 

W %responseBody
{produto:"CHP0001",Local:{IDMV: "000000001",LOTE: "",DtFabric: "null",DtVenc: "null",Atributo06: "0000000002",Atributo07: "",QtdeDisp: "10.00000",QtdeAloc: "0.00000",QtdeSep: "0.00000",QtdeTotal: "10.00000",Status: "OK",Motivo: ""}}

9
0 1050