9 Followers · 445 Posts

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

Question Andrew Hubbard · Nov 19, 2018

When using the JSON_OBJECT() function in Caché SQL on a %String property that contains JSON syntax, it converts the %String into a JSON object instead of escaping it as a string literal. How can I prevent this? (without ridiculous hacks like "add a space to the beginning of the value" as we don't always know which properties will contain these values and I certainly don't want to have to check for nulls and add/remove a space every single place this value is used in the application)

I don't want these strings automatically marshalled into JSON objects.

For example:

SELECT ID, JSON_OBJECT('ID': ID

12
0 1423
Question Anne Kantola · Jun 29, 2018

I try to test our REST/JSON (POST) services,where queryparametres are in content as json and the answer in contet is also as json.

This is my testClient:

Class XXX.RESTClient Extends %RegisteredObject
{
ClassMethod TestXXX()
{
#dim tRequest As %Net.HttpRequest = ##class(%Net.HttpRequest).%New()
set tRequest.ContentType="application/json"
json=##class(%ZEN.proxyObject).%New()
json.x="XXX" 
##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(.jsonStream,json)
set jsonText=jsonStream.Read(jsonStream.Size)
set tSC=tRequest.EntityBody.Write(jsonText)
set tSC = tRequest.Post("http://server:577

5
0 2292
Article Daniel Kutac · Apr 13, 2017 3m read

Recently, a partner company started to develop an Angular client for their Cache application. Together, we decided to leverage the power of Caché dynamic objects to exchange JSON encoded data between client and server parts. However, we realized that currently there is a gap in Cache JSON implementation that prevents simple use of traditional registered and persistent classes to exposed their data with the same ease as with XML. I wrote a small JSON adapter, that does the job and bridgers the gap. It's purpose is simple expose data described by a regular Cache class in a one-to-one fashion to a %DynamicObject. On the other hand, when a serialized JSON data comes in, it can be easily deserialized into dynamic object and subsequently bound to regular class by the newly created adapter.

7
1 2273
Question Anne Kantola · Mar 5, 2018

Hi, 

 
have you any working example of authentication and services in Angular 4 (2-5) and Cache 2017.1?
 
We have authentication, but we don't want CacheUsername and CachePassword to be in url (this works), but in header (we have not get this work, Problem 1).
We have REST services and they work with CacheUserName and CachePassword, but we want them work with cookie after authentication is done (we have not get this work, Problem 2).

How to code the client and what all we have to code and set on server?
 
We've tried last this (asked also WRC /Tomas, but not got the answer).
 
    private _loginUrl = 

10
0 2083
Question Duc Anh Tran · Oct 4, 2018

Hello everyone,

i want to create an iris document database with Atelier with some properties, where i can import my JSON formatted data from an API to the database which i created. Right now i know how to import my local JSON formatted data to my created database:

ClassUser.Classtest

{

ClassMethodgetFile()as%Status

{

               setfilename="/home/student/Downloads/own_scrobble.json"

               IF$SYSTEM.DocDB.Exists("db.Streamingdatabase"){

                              SETdb=##class(%DocDB.Database).%GetDatabase("db.Streamingdatabase")

                         

8
0 936
Announcement Stefan Cronje · Oct 7, 2018

Hi,

This is available on github and wairing for approval on the Open Exchange.

It  allows you to

  • "Serialize" any class instance that extends from the adapter to a DynamicObject.
  • "Deserialize" a DynamicObject to a class instance that extends the adapter.
  • References to other classes can be followed recursively and serialized.
  • Arrays and lists of Serial objects and DataTypes are handled for serialization en deserialization
  • Arrays and lists of Persistent objects can be serialized in full, on the deserialization it can't create referenced objects, but an array or list of ID values can be provided and it w
0
1 395
Question Hieu Dien Nguyen · Oct 4, 2018

Hi everyone,

I need submit a object have a json string as property of class, but I get an issue, object can't save to SQL table if I take json data to json property. I try making a test class with only json property and get the same issue, no data row in SQL table after run ClassMethod . Some one know what's problem, please help me. Here my test class:

Class DEMO.TestDocSource Extends %Persistent
{
Property jsonStorer As %String;
ClassMethod saveJson()
{
Set jsonStr = "{"
_"""k0"": {"
_"""k1"":""Default"","
_"""k2"":[ {"
_"""k21"":""Default"","
_"""k22"":""Default"","
_"""k23"":[]"
_"}],"
_"""k3"":null,"
_"""
2
0 895
Question Stephen Wilson · Sep 19, 2018
404 Not Found

{
"error": {
 "errors": [
  {
   "domain": "global",
   "reason": "notFound",
   "message": "Not Found"
  }
 ],
 "code": 404,
 "message": "Not Found"
 }
}

I want to do something like the above sample from a Google Storage JSON API. I have a call to Write obj.%ToJSON() followed by return ..ReportHttpStatusCode(..#HTTP404NOTFOUND) however the HTTP Status code is always 200.  If I remove the Write obj.%ToJSON() statement it returns a 404 status with no body. How do I return both?

1
0 2802
Article Eduard Lebedyuk · Sep 10, 2018 4m read

Generally speaking, InterSystems products supported dynamic objects and JSON for a long while, but version 2016.2 came with a completely new implementation of these features, and the corresponding code was moved from the ObjectScript level to the kernel/C level, which made for a substantial performance boost in these areas. This article is about innovations in the new version and the migration process (including the ways of preserving backward compatibility).

0
2 3298
Question Lyle McDaniel · Sep 6, 2018

Hello,
   We are running cache version  2012.1.4
Is it possible to make an HTTP Post passing in JSON string?

Example:
I want to send this request to Authorize.net. How can I do this in cache object script?

URL:  https://apitest.authorize.net/xml/v1/request.api

Body:

{
    "createTransactionRequest": {
        "merchantAuthentication": {
            "name": "gfufet9QVgT5P",
            "transactionKey": "8pg6FJjxuekeY62m"
        },
        "refId": "123456",
        "transactionRequest": {
            "transactionType": "authCaptureTransaction",
            "amount": "5",
            "payment": {
             

3
0 611
Question Andrew Makinson · Sep 3, 2018

In a EnsLib.REST.Operation I have...

Set tSC=..Adapter.Post(.tHttpResponse,,pRequest.stream)

This sends JSON string over HTTP

I am getting this error back from the server

ErrHTTPStatus: Received non-OK status 415 from remote HTTP server: 'HTTP/1.1 415 Unsupported Media Type'

I have been told that the media type should be "JSON"

how do I go about changing the media-type of the HTTP Request?

1
0 1247
Question Mitch Scobell · Jul 23, 2018

I'm trying to have my REST service return the entire data set for one of our legacy globals.  Currently I am parsing the object from a SQL statement into generic objects to be returned like this:


         Set specimenArray=[]
        
        WHILE resultSet.%Next() {
            Set specimen = {}
            Set specimen.SpecimenId= resultSet.SpecimenId
            Set specimen.ProjectId = resultSet.ProjectId
            
            Set Oref = specimenArray.%Push(specimen)
        }
        
        Set tProxy = specimenArray.%ToJSON()
        set %response.Status = 200
        set %response.ContentType

2
0 891
Article Chris Stewart · Apr 21, 2017 3m read

or "Didn't you say you would cover Persistent Objects in Part 5, Chris?"

Yes, that was the plan.  This is a pretty important topic, so it get's its own Article

Up until now, we've display widget JSON that has been created by a basic loop.  Clearly this isn't of much value.  Now we have our stack connected together, and we can see that the data is flowing to the Welcome page, it's time to complete the stack and start feeding our service from "real" data.


Let's start with our (very basic) Persistent class for Widgets.  We have 4 properties to hold Name, Description, Price and current Quantity.  We


4
0 1676
Question Jasenko Donlagic · Jul 3, 2018

Hi everyone,

I am still learning the platform for a student project and have to do some streaming and data analysis next. Since for my case I have no "live api" I wanted to just stream json files and output the data as it comes in from the files. (basically to emulate a incoming data scenario)

So thanks to the documentation and community posts I have figured how to create a stream and read data from a JSON but since I'm also new to JSON I have some parsing problems. I don't know how to access subarrays/sub-objects via objectscript.

The structure of the JSON File, I will omit some data becau

2
1 2942
Question Scott Roth · May 10, 2018

Is it possible to produce a .json format using Ensemble 2015.2.2? Not sure what the trigger will be as of yet, but we have our local Department of Health trying to develop a reporting piece using .json. 

Not sure how this will work with our Ensemble instance not being in the DMZ to send outside our network, but I thought I would ask anyway to see if it is possible.

Thanks

Scott Roth

2
0 409
Question Bob Felbol · Apr 20, 2018

Hi

Made a request for API REST.

Using HTTP Request adapter.

Adapter As EnsLib.HTTP.OutboundAdapter

Outside the Ensemble an API response is JSON (CORRECT)

Answer in Ensemble: =?Á
Â0 
?_eä,cÒ
'=
*^<YÙF¡í$í¼ÈÞÝt 
oÉ÷ý$?|
¤1¡{Dâhà°Ý?Öù)2ós??R?¸¼?ºd?$,ñD+»??

ÔºQZéýNÕ V{C?óò?b¢?éÍ )$ 
²5Å?wEë? ??©tÖã1z×2FëÊnôeË æ??]Zßq ܺ?á

Help me.

Thank you

8
0 588
Question Laura Blázquez García · Apr 20, 2018

Hello.

We have a request message with properties that has underscore. This is because we need to convert that request to JSON.

The problem is when we try to assign a value in a Business Process with the editor. It doesn't work, it doesn't compile.

How can we fix this?

This is the object used in the request: 

Class test.msg.struct.TestXML Extends (%SerialObject,%XML.Adaptor)
{
Property "status_id" As %String(MAXLEN = "");
Property service As %String(MAXLEN = "");
}

And this is the error:

Compilación iniciada en 04/20/2018 11:17:01 con calificadores 'k'
Compilando clase test.bp.TestBP
Compilando tabla test_b


8
0 1003
Question Bharathsimha Reddy Jakka · Apr 18, 2018

How to convert SQL persistent classes to JSON output - I have tried 1 option but appears to be very lengthy process.

I have many other SQL storage's defined and have to expose them as well to JSON. Can anyone please suggest a better approach.

My column names usually match with my Json properties.

My User.TestClass is the class with GetJsonList() as my method to return /output JSON formatted data.

The Code tried and SQL storage structure are as follows -

Class User.TestClass Extends %RegisteredObject
{
ClassMethod GetJsonList() As %Status
{
Set SQL="SELECT ID, Column1, Column2, DataID FROM SQLUser.Samp

3
0 1175
Question p rd · Mar 26, 2018

Server:

Class webservice.SOAPResponse Extends (%RegisteredObject, %XML.Adaptor){Property CustomerID As %String;Property Name As %String;Property Street As %String;Property City As %String;Property State As %String;Property Zip As %String;}

//--------------------

///
Class webservice.webServiceServer Extends %SOAP.WebService [ ProcedureBlock ]
{

Parameter SERVICENAME = "webServiceServer";

Parameter NAMESPACE = "http://tempuri.org";

Parameter USECLASSNAMESPACES = 1;

Method info(queryInfo As %String) As webservice.SOAPResponse [ WebMethod ]
{

   
6
0 2185
Question Kevin Furze · Mar 16, 2018

most of my jSON data is single words, but when it comes to sending chunks of a memo/email via JSON, that totally different

which is the correct conversion process to prepare data ready to insert into the data part of a JSON string so that all problem characters are converted

JSON of course crashes if you use the wrong format of quotes (single or double) and you ned up having to use &QUOT and \' to get around that but is there a simple call to something that will just take care of preparing the data from the JSON string both on the inward and outward part of JSON

kevin

13
0 652
Article Vitaliy Serdtsev · Nov 17, 2017 6m read

This series of articles aims to address the following topics:

  • Creation of a web application based on REST pages;
  • Overview of some tools for tracing (debugging) HTTP requests;
  • Switching from hyperevents to... hyperevents;
  • Integration with jQuery File Upload;
  • Conversion of JSON from the {id:1,parentId:1} format to the {id:1,children:[{}]} format for tree visualization;
  • Integration with jQuery EasyUI (using datagrid and tree as examples);
  • Other topics.
1
1 1097
Question George Hodder · Feb 16, 2018

I am trying to use the automated unittest class for a %CSP.Rest service.

So my Unittest code set's %request and %response from %CSP.Req/resp respectively

I build a tProxy with the fields I need for the post and set it %ToJson... I have tried seting %request.Content = tProxy (and not)

I call the method for the post url directly... 

  When that method calls %fromJson to set an object with the info. I passed... 

      - when I don't set %request.content.. I get a error '5035 - premature end of data code 12'

      - when I set %request.content=tProxy.. I get an errror Method Does not exist 
Any tips on w

7
2 1293
Question Paul Simon · Jan 19, 2018

I've been trying to interoperate with careevoltion using their backend-services.
Spec: http://docs.smarthealthit.org/authorization/backend-services/

This involves creating a JWT (JSON Web Token) that I have been unable to do using %OAuth2.JWT:ObjectToJWT.

I downloaded jwt.pfx and then ran the following openssl commands to create some pem files.

openssl pkcs12 -in jwt.pfx -out file.nokey.pem -nokeys
openssl pkcs12 -in jwt.pfx -out file.withkey.pem

openssl rsa -in file.withkey.pem -out file.key

cat file.nokey.pem file.key > file.combo.pem3

I then ran some node code to create the private

2
0 790
Question Sudarshan Kumar · Jan 12, 2018

(I am new to this language) I have got a JSON request to handle in a web application which is in %CSP.Request object. But the request which I am going to handle is of type array of objects.
like,

[
  {
    "Name": "bat"
  },
  {
    "Name": "Cat"
  },
  {
    "Name": "rat"
  },
  {
    "Name": "mat"
  },
  {
    "Name": "hat"
  },
  {
    "Name": "chat"
  },
  {
    "Name": "please"
  },
  {
    "Name": "help"
  },
  {
    "Name": "me"
  },
  {
    "Name": "in"
  },
  {
    "Name": "getting"
  },
  {
    "Name": "the"
  },
  {
    "Name": "value"
  },
10
0 2425
Question Nezla · Jan 15, 2018

Hi Guys,

I'm using the below code to Post JSON request to a REST API, but I'm getting "Failed to parse JSON request content." Error,

Set Body = ##class(%ZEN.proxyObject).%New()Set Body.ElectronicMailAddressT = "ElectronicMailAddressT"Set Body.TelephoneMinimalN = "TelephoneMinimalN"Set Body.AustralianBusinessNumberId = "AustralianBusinessNumberId"Set Body.OrganisationDetailsOrganisationBranchC = "OrganisationDetailsOrganisationBranchC"Set Body.DetailsOrganisationalNameT = "DetailsOrganisationalNameT"Set Body.PersonUnstructuredNameFullNameT = "PersonUnstructuredNameFullNa
7
0 6318
Question Nezla · Jan 15, 2018

Hi Guys,

I've a working that sent Http request to a REST API and is working fine,

Set Body = ##class(%ZEN.proxyObject).%New()Set Body.ElectronicMailAddressT = "ElectronicMailAddressT"Set Body.TelephoneMinimalN = "TelephoneMinimalN"Set Request.ContentType = "application/json"Set Request.Https=1Set Request.SSLConfiguration="TLS"Set Status = ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(Request.EntityBody, Body)Set Status = Request.Post(,2)

but now I'm looking to basically add an array or data inside the body so that it looks like this:

{
  "Elect
2
0 857
Article Jenna Makin · May 26, 2016 2m read

With the release of Cache 2016.1, JSON support was re-architected and made part of the core object model with the creation of %Object and %Array classes, which allow you to create dynamic JSON enabled objects and arrays.

On a recent demonstration I was working on, I had the need to create a REST web service that returned a JSON representation of a persistent object.  After searching for methods that would allow me to accomplish this, ultimately I found none, until now.

With the release of 2016.2 (currently in beta) we introduce the Document Data Model along with SQL enhancements that allow y

20
0 3035
Question Arun Kumar · Dec 1, 2017

Hi Guys,
Can you please guide me to get rid of this issue. Please find the image files with this post.

Please let me know, before we are developing an API what are all the setup/Configuration(Apache/web server) need to do in my machine. 

If any lead would be appreciated. 

I don't know, in XMLNamespace parameter which URL need to use.  

.

Thanks,

Arun Kumar Durairaj.

3
0 593