9 Followers · 447 Posts

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

Article Yuri Marx · Jan 12, 2022 12m read

The JSON is a data document free of types and validation rules. However, in some scenarios it is important that the JSON document has type and business rules validation, especially in interoperability scenarios. This article demonstrates how you can leverage a market-defined JSONSchema technology that is open for everyone to use and do advanced validations.

About JSON

According to json.org, “JSON (JavaScript Object Notation) is a lightweight data-interchange format.It is easy for humans to read and write.It is easy for machines to parse and generate.

3
2 1487
Question Ashok Kumar T · Aug 11, 2023

Hi Community,

Whenever I insert a decimal value with trailing zero(ex:12.0000) value in my JSON object dynamically through %Set method. It truncates the trailing zeros. However If I use literal constructors { } It working as expected.  So, In my case the JSON will be generated dynamically. I can't go with "Curly Bracket { } " and the JSON schema not string as well.
Is there any way to fix this?

set json = { "decimal": 12.000}
    zw json
    set json1= ##Class(%DynamicObject).%New()
    do json1.%Set("decimal", 12.000) ; this is consider as stringdo json1.%Set("decimal1", $FN(12,,2),
2
0 333
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:

Set myObjectA =
9
1 1064
Question Scott Roth · Jul 25, 2023

I am working on my first REST operation to send a API Request to an internal server within our Network. I have finally got past the point of being able to connect using a SSL/TLS Configuration, but I am getting a ERROR <Ens>ErrHTTPStatus: Received non-OK status 403 from remote HTTP server: 'HTTP/1.1 403 Forbidden'.

I have tried using $$$TRACE within my operation to capture the different elements that are being sent to verify the Server, URL, SSL Configuration, and payload. Is there a way that I can see the entire RAW request message that is being sent to see why I might be getting a 403 error

16
1 1134
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

I'm having an issue with consistently raising the alert (I've seen it raise an alert before, and then it wouldn't raise it again on a subsequent message), and also the error back does not really make sense.

0
1 371
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.

"meta": {
        "ve
4
0 925
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. 

So how does one go about creating a REST Operation if Learning Tutorials and Documentation always talks about REST services?

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()'

Reading the documentation I tried switching

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):

Class AH.AHLIB.Custom.Athena.Message.GetEventsSubscribedResponse Extends (Ens.Response, %JSON.Adaptor)
{

Pr
1
0 301
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.

Class User.Test Extends (%JSON.Adaptor, %RegisteredObject)
{ 

Property Name As %String(%JSONFIELDNAME = "name"); 

Property HexStream As
6
1 1637
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

The objects responsible for

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.

The most fascinating part of this is that even though we are able to learn any language and become fluent in it, we will always have our favorites – the ones we feel more comfortable and familiar with, and, as a rule, it has a lot to do with the

8
3 970
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?

Actually, since returning values in method arguments can be useful, this post demonstrates several ways to do this, between ObjectScript and Embedded Python. So let’s start with the simplest example: calling an ObjectScript method that already has a pass-by-reference argument from

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:

[
    {
        "codigo": "5128",
        "descripcion": "LAS ENFERMERAS FRENTE A LOS PROBLEMAS DE SALUD MENTAL",
        "programa": "Probabilidad de contagio ante un accidente hemático.",
        "admitido": 1,
        "desdefecha": "26/10/2022",
      
3
0 410
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 359
Question Oliver Wilms · Apr 13, 2023

I am trying to read binary data from HTTP Request Stream and build a Dynamic Object with multiple properties. I am getting MAXSTRING error with this code:

 Set dynObject1 = ##class(%DynamicObject).%New()
 Set dynObject1.OriginalFilename = $P($P(request.HTTPHeaders.GetAt("RawParams"),"&",2),"=",2)
 Set dynObject1.SiteId = $P($P(request.HTTPHeaders.GetAt("RawParams"),"&",1),"=",2)
 For {
   Set len = 1000000
   Set tRead = request.Stream.Read(.len,.sc)
   Set ^TESTutil($INCREMENT(^TESTutil),"len") = len
   Set ^TESTutil($INCREMENT(^TESTutil),"sc") = $Get(sc)
   If (len < 1) Quit }
   Set dynObject1.Str

5
0 763
Question Pravin Barton · Apr 18, 2023

I have a class using the JSON adaptor:

Class pbarton.test Extends (%RegisteredObject, %JSON.Adaptor)
{

Property Version As %String;

}

The Version property could be either a string or a number in the JSON source data. If it's a string, importing it will succeed. If it's a number, importing fails.

set t = ##class(pbarton.test).%New()

w t.%JSONImport({"Version": "3"})
1

zw t.%JSONImport({"Version": 3})
"0 "_$lb($lb(9406,"Version","class base",,,,,,,$lb(,"USER",$lb("e^%JSONImportInternal+16^pbarton.test.1^1","e^%JSONImport+12^%JSON.Adaptor.1^1","e^^^0"))))/* ERROR #9406: Unexpected format for
1
0 363
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 388
Article Zhong Li · Jan 23, 2023 11m read

Fun or No Fun - how serious is it?


Large language models are stirring up some phenomena in recent months. So inevitably I was playing ChatGPT too over last weekend, to probe whether it would be a complimentary to some BERT based "traditional" AI chatbots I was knocking up, or rather would it simply sweep them away. 
A thought comes to mind while playing.By going slightly theoretical or philosophical, eventually interoperability standards such as HL7 and FHIR etc are kind of "languages", right?HL7 has its own grammar, rules, vocabulary and even dialects - every system speaks its own tone.

3
1 1163
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 835
Question Claude Mourzelas · Feb 28, 2023

Hello,

I'm trying to populate an object with method :  JSONStreamToObject

This is an extract from my JSON:

 "GEOMETRIE_POINT": {
    "GEO_TAB_COORDONNES": [
      673993.9987,
      7048087.2013
    ]
  },
  "GEOMETRIE_LINE": {
    "GEO_TAB_COORDONNES": [
      [
        675221.6371,
        7049913.2718
      ],
      [
        675149.6053,
        7049998.3874
      ]
    ]
  }

It work fine with GEOMETRIE_POINT with this class definition:

Class Test.GEOMETRIEPOINT Extends (%Persistent, %JSON.Adaptor, %XML.Adaptor, %RegisteredObject, Ens.Request) [ Inheritance = right,
4
0 497
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.

The goal of this article is to

0
1 742
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 

  

set Httprequest = ##class(%Net.HttpRequest).%New()
  Set Httprequest.SSLConfiguration="RTLS"                              
   Set Httprequest.Server="vibra-api-prod.azurewebsites.net"                 
  Set Httprequest.Https=1
  Set Httprequ

4
0 290
Article Vivian Lee · Feb 27, 2023 4m read

Setting the Scene

Suppose you have the following 2 persistent classes that are both JSON-enabled (i.e. extends %JSON.Adaptor or %pkg.isc.rest.model.adaptor)

Class Test.Employee Extends (%Persistent, %pkg.isc.rest.model.adaptor) { 
  Parameter RESOURCENAME = "employee";
  Parameter firstName As %String;
  Parameter lastName As %String; 
  Relationship projects As Test.Project [ Cardinality = many, Inverse = employee) ];
}

Class Test.Project Extends (%Persistent, %pkg.isc.rest.model.adaptor) {
  Parameter RESOURCENAME = "project"; 
  Parameter name As %String; 
  Relationship employee
0
1 359