9 Followers · 455 Posts

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

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 712
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 1134
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.

7
2 1337
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
2
0 827
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 ).

My code is generating this JSON request:

{
        "AustralianBusinessNumberId":"AustralianBusinessNumberId",
        "CountryC":"CountryC",
        "DetailsOrganisationalNameT":"DetailsOrganisationalNameT",
        "ElectronicMailAddressT":"ElectronicMailAddressT",
        "Line1T":"Line1T",
        "Line2T":"Line2T",
        "LocalityNameT":"LocalityNameT",
        "OrganisationDetailsOrganisationBranchC":"OrganisationDetailsOrganisationBranchC",                                                                              "PayAsYouGoWithholdingTaxWithheldA":0.1,
        "Payee":[ {
                        "AllowanceTypeTypeC":"AllowanceTypeTypeC",
                        "BirthDate":"2014-01-11",
                        "CommunityDevelopmentEmploymentProjectA":0.1,
                        "CountryC":"CountryC",
                        "DeductionTypeC":0.1,
                        "DeductionTypeTypeC":"DeductionTypeTypeC",
                        "ElectronicMailAddressT":"ElectronicMailAddressT",
                        "EmployerContributionsSuperannuationGuaranteeA":0.1,
                        "EmployerReportableA":0.1,
                        "EmploymentEndD":"2014-01-11",
                        "EmploymentPayrollNumberId":"EmploymentPayrollNumberId",
                        "EmploymentStartD":"2014-01-11",
                        "ExemptForeignEmploymentIncomeA":0.1,
                        "ExemptIncomeFringeBenefitsReportableA":0.1,
                        "FamilyNameT":"FamilyNameT",
                        "GivenNameT":"GivenNameT",
                        "INBGrossA":0.1,
                        "INBTaxWithheldA":0.1,
                        "IndividualNonBusinessEmploymentAllowancesA":0.1,
                        "LabourHireTaxWithheldA":0.1,
                        "Line1T":"Line1T",
                        "Line2T":"Line2T",
                        "LocalityNameT":"LocalityNameT",
                        "LumpSumAA":0.1,
                        "LumpSumAC":0.1,
                        "LumpSumBA":0.1,
                        "LumpSumDA":0.1,
                        "LumpSumEA":0.1,
                        "OrdinaryTimeEarningsA":0.1,
                        "OtherAllowanceTypeDe":"OtherAllowanceTypeDe",
                        "OtherGivenNameT":"OtherGivenNameT",
                        "PostcodeT":"PostcodeT",
                        "StateOrTerritoryC":"StateOrTerritoryC",
                        "TaxFileNumberId":"TaxFileNumberId",
                        "TaxableIncomeFringeBenefitsReportableA":0.1,
                        "TelephoneMinimalN":"TelephoneMinimalN",
                        "TerminationPaymentSummary":[ {
                                        "EmploymentTerminationPaymentTypeC":"EmploymentTerminationPaymentTypeC",
                                        "PaymentRecordPaymentEffectiveD":"2014-01-11",
                                        "SuperannuationEmploymentTerminationTaxableComponentTotalA":0.1,
                                        "SuperannuationTaxFreeComponentA":0.1,
                                        "TaxWithheldA":0.1
                                }
                        ],
                        "WorkingHolidayGrossA":0.1,
                        "WorkingHolidayTaxWithheldA":0.1
                }
        ],
        "PaymentRecordTransactionD":"PaymentRecordTransactionD",
        "PersonUnstructuredNameFullNameT":"PersonUnstructuredNameFullNameT",
        "PostcodeT":"PostcodeT",
        "TelephoneMinimalN":"TelephoneMinimalN",
        "TotalGrossPaymentsWithholdingA":0.1
}
7
0 6389
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

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

{
  "ElectronicMailAddressT": "string",
  "TelephoneMinimalN": "string",
  "Emp": [
    {
       "EmploymentPayrollNumberId": "string",
      "TaxFileNumberId": "string",
      "FamilyName": "string",
      "GivenName": "string",
        "PaymentSummary": [
        {
          "Tax": 0.1,
          "SuperTax": 0.1,
            }
      ]
    }
  ]
}
2
0 879
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.

20
0 3132
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 610
Question Tom Philippi · Nov 27, 2017

How do I set an URL when I post a httpRequest via SendFormArray of my Ensemble Business Operation. Here is my code: 

Class CareHome.RestApiClient Extends EnsLib.REST.Operation
{
Parameter INVOCATION = "Queue";
Method Login(pRequest As CareHome.Request.LoginRequest, Output pResponse As Ens.StringResponse)
{

set tURL = ..Adapter.URL_"login/login"


set httpRequest = ##class(%Net.HttpRequest).%New()
 set httpRequest.ContentType="application/json"
 do ..ObjectToJSONStream(pRequest,.jsonStream,"aeliw")
 set httpRequest.EntityBody = jsonStream
  
 set tSC = ..Adapter.

1
0 970
Article Sean Connelly · Aug 21, 2017 3m read

If you want to dynamically serve images as a property of JSON then there is no perfect encoding solution. One method used frequently is to Base64 encode the image. Whilst there are some negatives to doing this, such as data inflation, there are some positives to working with Base64 images inside the browser.

Let's say you have an image placeholder on a web page...

<div id="image-container"><div>


And you fetch a JSON message from the Caché server containing the image as one of its properties...

var msg = JSON.
4
1 1968
Article Ward De Backer · Oct 9, 2017 6m read

One of the most important features during application development is the ability to debug your code easily. Because of the asynchrnous nature, a standard Node.js application server works single-threaded by default. When you are developing applications using an IDE like Visual Studio Code, you can very easily debug your Node.js process:

First, download the free Visual Studio Code IDE (@code) and install it on your development machine.

We will start with basic debugging using a very small test.

0
0 2334
Question Soufiane Amroun · Sep 28, 2017

Hi , i have a JSON record as follow {value1,value2, value3}

i want to write my switch statement in this form:

<switch> my value
<case> value1</case>
<case>value2</case>
<case>value3</case>
​</switch>

is there any possibility to extract values from JSON record and put them in a  switch statement?

thank's

1
0 2533
Article Maks Atygaev · Jul 18, 2017 7m read

MonCaché — MongoDB API implementation based on InterSystems Caché

Disclaimer: This article reflects author's private opinion and has no relation to the official position of InterSystems.

IDEA

The idea of the project is to implement basic MongoDB (v2.4.9) API features for searching, saving, updating and deleting documents in a way that will allow the use of InterSystems Caché instead of MongoDB without changing the code on the client side.

MOTIVATION

Perhaps, if we take an interface based on MongoDB and use InterSystems Caché for data storage, we may see a performance boost.

14
0 1993
Article Chris Stewart · Sep 8, 2017 3m read

a.k.a..  "The World of Widgets Returns!" or "Paternity leave damages Instructional Series momentum"

In our last lesson, we combined 2 separate classes to appear as the same property.  We now have the ability to Update our Widget catalog, but what if we want to Create a Widget?  Thankfully, we've already done 90% of what we need, just by implementing Edits

0
0 1103
Question Nael Nasereldeen · Aug 31, 2017

Hi guys,

How do you deal with underscore characters when using jsonProvider  and exporting or importing ?

for example:

USER>s jsonString="{""what"":""1"",""up"":""2"",""test_test"":""3""}"
 
USER>set status = ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(jsonString,,.outputObj)
 
USER>w outputObj.what
1
USER>w outputObj.up
2
USER>w outputObj.test_test
 
W outputObj.test_test
^
<UNDEFINED> *test

we found out that we can access it like this, but not sure if it's the recommended method-

w outputObj.%data("test_test")

Regards,

Nael

11
0 718
Article Rob Tweed · Jul 31, 2017 5m read

In my previous posting about the new support in QEWD for JSON Web Token (JWT) support, I mentioned that it was a key step in enabling Micro-Service support in QEWD.  In this post I'll give some background to how they work and the thinking behind them.

If you haven't heard about Micro-Services and/or want to learn more, there's lots of information available if you do a Google Search.  Here's a good starting point:

https://smartbear.

3
0 908
Question Craig Regester · Aug 30, 2017

Good afternoon - 

I'm in the process of learning to make COS calls to REST-based web services and while I am having success, I'm struggling on how to parse out the results (I admit I'm very green at this):

Here's the code retrieving the JSON response:

w !,"Get the JSON"Set 

This has Result as a Library.DynamicObject.

I can then write out the response using:

.

This works, I can see the response is valid and what I want. Here is the JSON returned (de-identified):
 

4
1 1468
Question Pedro Borges · Aug 14, 2017

Hello -- Is there a way to load a JSON from a file.

I have a "JSON" file which has a sting 1035164 long with the following format: 

[
    {
        "id": "12345",
        "title": "John Smith",
        "image_uri": "https://<some URL>",
        "image_timestamp": "1496781334",
        "image_url":"https://<some URL>

There are ~ 4839 entries. 

Is it possible to parse a JSON string by loading a from a file?

I tried this.

15
0 2865
Article Rob Tweed · Jul 31, 2017 7m read

If you read my previous post that introduced QEWD Micro-Services, you're hopefully eager to learn how to use them.  So in this post I'll explain what you need to know in order to get started.

If you look in the QEWD repository, you'll find the folder: 

  https://github.com/robtweed/qewd/blob/master/example/jwt

In my earlier post on JSON Web Tokens (JWTs) and QEWD I used this example application to explain how to use JWTs.  This example application also demonstrates how to set up a simple Micro-Service, in this case a service that handles user authentication.

0
0 622
Question Jose Antonio Cañizares · Jul 14, 2017

Hi all,

We faced a problem where we would like to map a $lb object to its corresponding data model structure in order to later on export it as JSON.

So imagin that we have something like this that actually maps to a persistent table with its structure. 

$lb("",,,,,"",,,"BOOLEAN","0",2,2,"1",,"bla",$lb(,,"bla","20050502123400"),"",1,"bla",,0)

Is there a way to transform this $lb (without the need of openig the object itself) to a JSON object with the proper table fields as properties?

Many thanks

9
0 632
Question Alexander Koblov · Feb 5, 2016

Hi.

It is easy to receive JSON representation or dynamic Array from %ListOfDataTypes:

set l=##class(%ListOfDataTypes).%New()
do l.Insert("a")
do l.Insert("b")
do l.Insert("c")

set arrStr=l.$toJSON()
zwrite arrStr
set arr=l.$compose([])
zwrite arr

How to make backward conversion? How to receive %ListOfDataTypes from dynamic Array an JSON string?

I've tried

SAMPLES>set list = ##class(%ListOfDataTypes).$fromJSON("[""a"",""b"",""c""]")

%FromObject+21^%Library.RegisteredObject.1 *%Exception.General Compose Compose %FromObject Unable to map from %Library.Array instance to %Library.ListOfDataTypes
3
0 1558
Question PILAR GUERRERO · Jun 29, 2017

Hello...

I need to convert a array  (JSON) in a List Of String. I think, there is some method that does it directly.

Something like that:

SAMPLES>set list = ##class(%ListOfDataTypes).$fromJSON("[""a"",""b"",""c""]")

%FromObject+21^%Library.RegisteredObject.1 *%Exception.General Compose Compose %FromObject Unable to map frm %Library.Array instance to %Library.ListOfDataTypes

I have reading about this but I don't found some trick to help me.

https://community.intersystems.com/post/how-convert-json-listofdatatypes

Thanks!!

1
0 669
Article Sean Connelly · Jun 7, 2017 1m read

The Cogs.JsonClass library is now available in the Cogs project on GitHub.

https://github.com/SeanConnelly/Cogs

Please see the README and the /docs folder on how to use the class.

Overview

The Cogs.JsonClass class provides a one step serialisation and deserialisation to and from Caché registered and persistent classes. It is not dependent on any other code and should be compatible with older versions of Caché.

The unit tests have been included in the update, but until I release the dependent Touchstone unit test solution it won't be possible to run these tests.

5
0 750