JSON

Syndicate content 16 

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.parse(client.responseText);


Without needing to decode the image data you can create an img element and append it directly to the place holder..

Last comment 7 November 2017
1 5
812

views

+ 6

rating

The Widgets Direct sample application highlights many aspects of how to use InterSystems technologies to build a modern web application.  Features include:

  • Angular Material + AngularJS + JSON + REST based interactive application with Step by Step instructions on how it was built
  • Example scripts for server-side source control configuration with Perforce
  • %UnitTest logic for automated regression testing
  • %Installer class for automated instance installation from source control 
  • Scripts for Continuous Integration (CI) with Jenkins
  • Docker Manifest for automated provisioning of an instance

We will be adding articles which discuss the above list of features to drill down in more detail on each topic (feel free to  comment if there is something you want to see done sooner rather than later)

Last comment 23 October 2017
0 6
796

views

+ 5

rating

Hi, Community! 

Check a new  session recording from Global Summit 2017:

Angular, JSON, and REST – Oh My!

 

0 1
0

comments

286

views

0

rating

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.js file and go to the debug view:

You'll notice we need to define a debug configuration first (at the top, click on "No configurations" and select "Add configuration". You'll see a "launch.json" file is created and select "Node.js: launch program":

0 2
0

comments

910

views

+ 3

rating

I've mentioned the QEWD project in this group before: it's a Node.js-based platform for web, Native and REST applications which tightly integrates with Cache.  It uses a somewhat different philosophy to the use of Node.js than the norm, and I've now published an article that explains this approach and the unique benefits that arise as a result.

It turns out that, integrated via QEWD, Cache is an ideal bed-fellow for Node.js.  QEWD makes the integration of Cache and Node.js exceptionally fast, simple and intuitive to use, but also extremely powerful.

Read the article here: 

https://robtweed.wordpress.com/2017/04/18/having-your-node-js-cake-and-e...

If you're interested in using Cache with Node.js, you really need to take a look at QEWD!

Last comment 25 September 2017
0 4
283

views

+ 4

rating

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

Last comment 13 September 2017
0 8
1048

views

+ 9

rating

Hi,

I would like to draw your attention on a recently published article, titled "A Quick Guide on How to Prevail in the Graph Database Arena", that has been posted also at LinkedIn. Intersystems Caché has been referenced several times. In the "Multi-model Database Engine" section of this article, there is a quick description of Caché  as a

Last comment 11 September 2017
0 2
561

views

+ 2

rating

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

As we mentioned when creating the REST Services for PUT and POST, the only real difference between creating and updating a record is whether we are passing in an existing ID or creating a %New record.  The actual content of the Widget JSON is exactly the same, so this allows us to be a little lazy and reuse the form and controller code we have previously written, with just some minor edits to allow it to work for New Widget

0 1
0

comments

323

views

0

rating

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

Last answer 31 August 2017 Last comment 5 September 2017
0 2
203

views

0

rating

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.com/learn/api-design/what-are-microservices/

Last comment 5 September 2017
0 3
329

views

+ 3

rating

Cogs Library

Over the next few months I will be releasing a number of open source libraries and tools to the Caché community.

Most of the code has evolved from previous production grade solutions over the years and I am collating it together under a single overarching library package that I am calling Cogs.

Last comment 4 September 2017
0 5
853

views

+ 12

rating

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 Result = {}.%FromJSON(Request.HttpResponse.Data)

This has Result as a Library.DynamicObject.

I can then write out the response using

Last answer 30 August 2017 Last comment 30 August 2017
0 1
479

views

0

rating

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>",
        "is_restricted_under_18_only": false,
        "is_restricted_adult_only": false
    },
...
    {
        "id": "67890",
        "title": "Mary Jane",
        "image_uri": "https://<some URL>",
        "image_timestamp": "1496781334",
        "image_url": "https://<some URL>",
        "is_restricted_under_18_only": false,
        "is_restricted_adult_only": false
    }
]

There are ~ 4839 entries. 

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

I tried this..

Last answer 14 August 2017 Last comment 15 August 2017
0 3
763

views

0

rating

Developing a Full-Stack JavaScript web app with Caché requires you to bring together the right building blocks. Previously, I outlined the basic steps to install and connect Node.js to Caché and make it's powerful multi-model database capabilites available for use with Node.js. You can use Caché as a NoSQL-, document- (with unique key-level access!), SQL- and object-database with Node.js. When developing JavaScript applications, you'll see how powerful this combination is and makes Caché a perfect fit for Node.js.

In the first part of this article series I will show how to get started with the React framework, one of the most popular frameworks currently taking over front-end development. In the next parts you'll learn how to connect a basic web app to a Caché back-end.

You'll see, it's very easy to get started with this technology - you can even compare the amount of basic knowledge you need to COS because you only need to know a few basic concepts to start!

Last comment 8 August 2017
1 14
3139

views

+ 8

rating

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.  So let me now delve into that aspect of the example application.

If you're wanting to use QEWD Micro-Services, you must also use JWTs - these provide the means by which the user's authentication and session can be cross-communicated and handled by multiple, discrete QEWD servers.  So, take a look at the startup file

0 2
0

comments

225

views

+ 1

rating

Hi All,

We have a application currently running on Zen framework, now business wants to use Angular JS as their front-end technology for any future release but they don't want to upgrade the existing the modules which are already there in Zen (as of now).

Last answer 25 July 2017 Last comment 27 June 2017
0 1
235

views

0

rating

Hello,

Are there any utilities/api in HealthConnect 2016.2.1 that will allow conversion of XML virtual document to Json format? We were thinking to convert HL7 ADT message to XML via Ensemble DTL and then send it to another BP to convert to Json format for transmission via Web Services. To my understanding there isn't anyway to represent Json as a virtual object so it can be use for direct mapping of HL7 2.x message to Json via Ensemble DTL.

Thanks

Yuriy

Last answer 20 July 2017 Last comment 15 May 2017
0 1
975

views

0

rating

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

Last answer 14 July 2017 Last comment 14 July 2017
0 4
213

views

0

rating

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

and

SAMPLES>write arr.$compose(##class(%ListOfDataTypes).%New())
 
zcompose+44^%Library.AbstractObject.1 *%Exception.General Compose Compose %FromObject Unable to map from %Library.Array instance to %Library.ListOfDataTypes
Last answer 30 June 2017 Last comment 8 February 2016
0 3
680

views

+ 2

rating

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.

Please report any issues on the GitHub issues log.

I will post some benchmarks later in the week.

Sean.

Last comment 8 June 2017
0 6
446

views

+ 5

rating

Hi!

I have a question:

I create a Operation REST API , when I call to my client trough this REST API, my cliente returns list of object in JSON, like that:

[
    {
    "Center" : "aaaaaaaaaa",
    "Nif" : "00000000T",
    "NumberCenter" : "00000000",
    "Name" : "ppppp",
    },
    {
    "Center" : "aaaaaaaaaa",
    "Nif" : "00000000T",
    "NumberCenter" : "00000000",
    "Name" : "ppppp",
    },
    {
    "Center" : "aaaaaaaaaa",
    "Nif" : "00000000T",
    "NumberCenter" : "00000000",
    "Name" : "ppppp",
    }
]

On the other hand, I have in my Ensemble, Two class:

Class A --> lisf of class B

Class B --> Center, Nif,NumberCenter, Name

I need to iterate over JSON and capture de information a put this in my object A

I have been investigating... And I found a approximation that i want to do...

First of all, I want to iterate over JSON and capture de informatio

Last answer 1 June 2017 Last comment 2 June 2017
0 4
383

views

0

rating

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 = ##class(A).%FromJSON(%request.Content)

 

Any suggestions? Thanks.

Last answer 1 June 2017 Last comment 2 June 2017
0 0
385

views

0

rating

As Bill has mentioned earlier in his post, we have carefully reviewed the JSON capabilities and made some adjustments to ensure they deliver the best benefit to you. In this post, I am going to describe the modifications in more detail and provide guidance for you to understand the implication for your code base.

Last comment 30 May 2017
0 12
2453

views

+ 11

rating

In our last lesson, we added some formatting and validation to our Edit Widget form.  So, now we are ready to add the ability to add new Widgets to our application.  However, the great Widget Wars have come to an abrupt end, as Widget Direct has purchased its biggest competitor, WorldWideWidgets.  In order to maintain some continuity, we need to display their catalog on our new application.

So, we have good news and bad news.  The good news is at that WorldWideWidgets also use Caché, but the bad news is that their Widget table has different properties with different names than our Widget class, and we need to keep the catalogs seperate for the time being.  WorldWideWidgets don't have a WidgetAccessory catalog (and they wonder why they lost the Widget War), so we don't need to worry about Accessories for no

0 2
0

comments

299

views

+ 2

rating

In our last lesson, we added a form to Edit our existing Widgets, and save them back to the server.  However, our Form was not well structured and our Save button had no intelligence, and was not fully visible.  So today, we will apply some Material components and Angular style to make the form more useful

Let's open EditWidget.csp, and make some changes.  First, we want to change the component from an md-card to an md-dialog.  We then want to wrap the content in a div so we can set the layout to "column" so the controls display in a vertical list, and also a Form which enables Angular to verify the state of the form

0 4
0

comments

299

views

+ 2

rating

We finished our last lesson with our Widgets Direct page iterating over a list of widgets, displaying an ID and a Name value.  While we have been able to achieve this with only a small amount of coding, the page itself is not the most visually appealing place to be.  The AngularJS framework is providing a powerful Model-View-Controller framework for our structure and logic, but it does not implement anything that will provide a nice UI experience.  For that we need to implement a UI toolkit.  We have numerous options here; the leading toolkits are BootStrap from Twitter and Angular Material from Google.  There are advantages and drawbacks to each choice.  It is well worth exploring demos of each toolkit to see which would fit your need

Last comment 25 April 2017
0 5
721

views

+ 6

rating