9 Followers · 445 Posts

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

Question Javier Gonzalez · Jun 1, 2017

I'm doing a REST service. A method has as body parameter a JSON corresponding to a class A.

In my production I have class A so that I retrieve the parameters using a dynamic object, such that:

Set body = ##class(%DynamicObject).%FromJSON(%request.Content)
Set myObjectA = ##class(A).%New()
Set myObjectA.Id = body.Id
Set myObjectA.Name = body.Name
Set myObjectA.Date = body.Date
Set myObjectA.Salary = body.Salary

I would like to know if I can avoid doing the manual mapping, doing a casting, since I am sure that FromJSON will return a class A. Something like this:

9
1 1063
Question Lewis Houlden · Jul 20, 2023

Hi InterSystems Community

We recently had an issue where we weren't able to parse a JSON HTTP request, but the issue went by unnoticed. We also did not have a trace of what the raw HTTP request was that we couldn't parse. I'm looking at improving our this by:
Tracing the raw request using $$$TRACE

Raising an alert which will hit our Ens.Alert router which will compose and send an email

0
1 370
Question Jordan Simpson · Jun 23, 2023

Hi,

I'm trying to figure out why I'm unable to iterate through a dynamic array and access the nested objects.

Using the NHS PDS FHIR API in the NHS sandbox environment, I'm querying the PDS endpoint using a sample NHS Number to retrieve a patient's demographics. My Business Operation reads the response data and passes it back to my Business Process where I intend on iterating through certain nested objects. The data present in these nested objects will decide what happens next in the process.

In the JSON snippet below, I'm attempting to access the values of code and display.

4
0 917
Question Scott Roth · Jul 6, 2023

I had attempted to create a REST Operation before but did not have success. As I am going through the Tutorials and Documentation everything references REST services, but I have a case where I want to create a REST Operation that makes Epic API calls against Interconnect. I have done SOAP operations before and we currently have one in our Production Namespace, but from what I understand SOAP has the wsdl which defines al the structures and etc, where REST does not. 

1
1 341
Question Scott Roth · Jul 7, 2023

I am playing around with trying to make an Epic REST API call from an operation, and from what I understood because the request has to be sent as POST, I need to send the request as JSON. However when I try taking the request and running %ToJSON against it for the payload to be created I am getting an error...

ERROR <Ens>ErrException: <METHOD NOT SUPPORTED>zgetPatientLocationByVisit+6^User.SCOTT.REST.APIOperation.1 *%ToJSON,osuwmc.Epic.Access.Request.GetPatientLocationByVisit2JsonRequest -- logged as '-' number - @' set tPayload = tRequest.%ToJSON()'

3
0 436
Question Samantha Forish · Jun 16, 2023

I am working with a REST API JSON Response that contains a list of integers (departmentids).

JSON Response:

{
"status":"ACTIVE",
"departmentids":[
72
],
"subscriptions":[
{
"eventname":"LabResultAdd"
},
{
"eventname":"LabResultUpdate"
},
{
"eventname":"LabResultClose"
}
]
}

 

I am having trouble getting that to parse into my custom message structure using the %JSONImport method.

do pResponse.%JSONImport(tHttpResponse.Data.Read())

Here is my custom message class (pResponse):

1
0 298
Question Dmitry Maslennikov · Apr 30, 2020

Okay, we've got a quite useful way to very easily Import and export our objects as JSON, similar to what we already had before for XML.

So, It's a %JSON.Adaptor. But the issue here I faced with, working with Stream properties. 

I have an example, when I generate an object, with stream binary stream properties. Export and Import the same, but getting the different resulting objects, depends on the original size of streams.

6
1 1632
Article Cristiano Silva · May 27, 2023 6m read

How many times do we find ourselves rebuilding, copy-pasting, adapting, Business Operations that make calls to REST services, and only adapting one or another part of the final code. This is annoying a lot. To resolve this our inconvenience, I present to you Interopway REST, a set of classes (a micro framework) that allows us to just add Business Operation to Production and use it.

The project is hosted on github, https://github.com/cristianojs/interopway_rest, it is open and we are accepting collaborations.

Let's understand how this works.

Transport Objects

0
1 394
Article Heloisa Paiva · May 3, 2023 10m read

Programming and languages

Being a programmer nowadays is basically the geek version of being a polyglot. Of course, most of us here, in the InterSystems Community, “speak ObjectScript”. Howeever, I believe this wasn’t the first language for many people. For instance, I had never heard about it prior to getting the appropriate training at Innovatium.

8
3 969
Article Joel Solon · May 23, 2023 5m read

Methods written in ObjectScript can use pass-by-reference arguments to return information to the caller. Python doesn’t support pass-by-reference arguments, so Embedded Python in IRIS doesn’t support them either. That's it, that's the end of the post, hope you liked it. 😉 But wait, what about the Classic Rock & Roll?

1
1 636
Question Yone Moreno · May 16, 2023

Good morning:


Thank you very much for reading the doubt and above all thank you very much for answering.

Given the following use case:

If we have a Destination Service that through a HTTP GET by REST gives us a certain JSON response, where it should be noted that it is a list of objects where each object in the list does NOT have a key:

3
0 409
Question John McBride · May 2, 2023

Hello All, 

I'm trying to sign some custom JWT with x.509 certs but running into a problem with the signed JWT containing some information I need in the JOSE header.

Is there a way to get the "X5C:[]" header included in the signed JTW? IS this as easy as setting something like the following

Set JOSE("x5c") = "public key"

Thanks

John

1
0 353
Question Robert Cemper · Mar 17, 2023

There is an example on JSON XDATA.
But it only describes Name mapping.

Is it possible to define somehow also a structural mapping
e..g an Array of Arrays Structure: without property names

[
     [12,33], [88,44]

1
0 590
Question Shaun Munro · Mar 27, 2023

When using %JSONImport it seems to only report a single error, is there a way to report all the errors with out having to do multiple requests?  

{

    "errors": [

        {

            "code": 9406,

            "domain": "%ObjectErrors",

            "error": "ERROR #9406: Unexpected format for value of field, CurrencyCode, using Update mapping",

            "id": "JSONImportError",

            "params": [

                "CurrencyCode",

                "Update"

            ]

        }

    ],

    "summary": "ERROR #9406: Unexpected format for value of field, CurrencyCode, using Update mapping"

}

1
0 386
Question Oliver Wilms · Mar 21, 2023

Hello, I want to show a fellow DC member how to convert JSON file into HL7 message. I personally do not work with HL7. I set up a production with EnsLib.File.PassthroughService. It passes Ens.StreamContainer to BPL process. I call a DTL to transform StreamContainer to HL7 message. I run into an error:

ERROR <Ens>ErrBPTerminated: Terminating BP JSON2HL7 # due to error: ERROR #5035: General exception Name 'Parsing error' Code '3' Data ''
> ERROR #5035: General exception Name 'Parsing error' Code '3' Data ''

The code is in this GitHub repo:

https://github.com/oliverwilms/HL7

2
0 834
Article Elliott Grey · Mar 7, 2023 10m read

Foreword

InterSystems IRIS versions 2022.2 and newer feature a redesigned functionality for JSON web tokens (JWTs). Once housed under the %OAuth2 class package, the JWT class, along with other JSON web classes (JWCs), now live under %Net.JSON. This migration occured in order to modularize the JWCs. Before, they were closely intertwined with the implementation for the OAuth 2.0 framework. Now, they can be maintained and used separately from OAuth2.

Note: For backwards compatibility, the classes still exist under %OAuth2 package, but the codebase now uses %Net.JSON.

0
1 740
Question Nezla · Mar 2, 2023

Hi Guys,

I'm using the below code but I'm getting an uncomplete JSON file, so it seems that the command S obj=Httprequest.HttpResponse.Data.Read(Httprequest.HttpResponse.Data.Size) is not reading the whole file, so maybe the file is too big so is there a max size or can I change something in my call ?

The uncomplete file that I received so far is about 3.5MB 

  

4
0 289
Article Heloisa Paiva · Feb 22, 2023 4m read

Why I've decided to write this

Once again I had a challenge that costed me some time and a lot of testing to reach the best solution. And now that I've managed to solve it, I'd like to share a little bit of my knowledge.
 

What happened?

In a namespace there were a lot of similar classes, so to make them simpler there were a superclass with comon properties. Also, there are relationships between them. I had to export one of them to JSON, but I couldn't change the superclasses, or I would break down the flow of many other integrations.

0
2 485