JSON

Syndicate content 16 

At the end of our last lesson, we ended with our page displaying a nice (but garish) Angular Material Toolbar, and our Widget data displaying in a list of Material cards.  Our page feels a bit static, and we already know that the large number of Widgets that we will be dealing with will not be especially usable on a static list.  What can we do to help?


A filtering function would be very helpful, so let's add a text input to the top of the page. We will bind this to a variable in the $scope - widgetFilterText so that Angular has access to the value we type in. We will also wrap the whole page content in a div and set layout="column" to have the new text input and the existing cards arrange vertically on the screen

0 0
0

comments

481

views

+ 3

rating

Hi All,

I use SQL function JSON_OBJECT to get data as a JSON object.

However, sometimes I get error with function JSON_OBJECT when values contain [, ], { or }.

Error:

[SQLCODE: <-400>:<Fatal error occurred>]

Unexpected error occurred in JSON_OBJECT() function execution of <JSON_OBJECT>.%FromJSON().Parsing error

For example,

Query: SELECT JSON_OBJECT('idSQL':id, 'content':content) FROM DocBook.block

For demonstration, I used Management Portal, System Explorer – SQL, Execute Query

This text was in Content:

{&quot;Info&quot;:{&quot;Error&quot;:&quot;ErrorCode&quot;:&quot;5001&quot;,&quot;ErrorMessage&quot;:&quot;ERROR #5001: Cannot find Subject Area: &#39;SampleCube&#39;&quot;} } }

If I delete all { and } from Content, I don’t get this erro

Last answer 20 April 2017 Last comment 20 April 2017
0 0
678

views

0

rating

We finished our last lesson with our Widgets Direct page receiving a Welcome message as a property of a JSON object, which was unpacked and displayed on the page. However, we are on Lesson 3, and we still haven't had any talk of displaying widgets yet.  

Let's change that.  Widgets Direct are a leader in widget and widget accessories, so we clearly have numerous items to display.   To transfer this, we will need to declare and return our first array.  Let's go back to our REST.Dispatch class, and add this data to our Service

0 5
0

comments

677

views

+ 4

rating

or "So you just got yelled at by your boss, for sending him an unformatted Hello World webpage"

Our previous lesson ended with us serving a Message value obtained from a Caché REST service to the client, using Angular as a runtime.  While there is a lot of moving parts involved in this process, the page is not especially exciting at the moment.  Before we can start adding new features, we should take a step back and review our tools.


This tutorial is using the JSON functionality built into 2016.2+ versions of Caché.  This functionality is partially available in 2016.1 but utilizes a different syntax which will not be forward compatible.

0 6
0

comments

1029

views

+ 11

rating

Hi everyone, I have and Zen Mojo application, it's all working but I have some doubts about what is recommended to use: There is some reports of employees, for example, and actually I'm using some plugins : "Excelent export" to generate Excel reports and "jspdf" to generate PDF reports in client side.

I have an REST service, that receives the request, process and returns JSON, after client side receive the response it's processed.

- This can be slow/bad in applications with large data?

- It's better/recommended to use ZenReports even with ZenMojo applications?

- Or Zen Mojo, like any other applications based on HTML, JS and PHP can support this with any problem?

- The preparation of the JSON is very fast because the use of %DynamicObject and %DynamicArray; ZenReport can be slower than it?

 

Thanks,

Andrei L. Nenevê

Last answer 24 February 2017
0 0
0

comments

188

views

+ 1

rating

Hi all,

I'm trying to convert a HL7 section to a XML or JSON string.

We need to save the content of PID section into a SQL Column, therefore we need to convert it into a XML o JSON string

is there any easy way to convert it?

I've tried to convert it directly into a DTL, but all my attempts have been unsuccessful

Best regards,

Francisco Lopez

Last answer 22 December 2016 Last comment 20 December 2016
0 0
474

views

0

rating

How can I prevent large number truncation when using the DynamicObject and DynamicArray classes to create JSON in objectscript and then parsing the result in javascript. Are there any global settings that configure the output when using these classes?

 

I am looking at converting to the new DynamicObject and DynamicArray classes to build JSON. Our current (homegrown) JSON library forces string representation of numbers too long because of errors we were seeing with long numbers being truncated on the client, I am hoping to accomplish the same with the new classes.

 

USER>set longNum = 1234567890123456789
 
USER>w longNum
1234567890123456789   //valid cache  number, 19 digits
USER>s arr = [(longNum)]  
 
USER>w arr.%ToJSON()
[1234567890123456789]   //Valid JSON, however I would like this to be a quoted string so it can be parsed in javascript

//Parsed in javascrip

Last comment 9 December 2016
0 3
0

answers

394

views

0

rating

Hi,

I am working with this Ensemble Business Operation, which extends the EnsLib.Rest.Operation.

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

I built the OpenWeatherMap Rest Operation described in the article above.

I would like to access the weather.id weather.main, and weather.description. However, these objects are in a JSON Array.

How do you access these three objects in Objectscript.

In my,  Test.REST.WeatherOperation class, I added these three lines.

            set pResponse.WeatherId = tProxy.weather.id
            set pResponse.WeatherMain = tProxy.weather.main
            set pResponse.WeatherDescription = tProxy.weather.description

Last answer 9 December 2016 Last comment 9 December 2016
0 1
378

views

0

rating

Is there any way that I can check the native type of an object script variable? (similar to the typeof check in javascript)

 

I see that the DynamicArray class uses the type of the variable for its output, I would like to do something similar when I receive a value as an argument to my method.

USER>s var1 = 123  //No quotes, number type
 
USER>s var2 = "123" //quotes, string type
 

//DynamicArray can tell the difference
USER>s arr = []
 
USER>d arr.%Push(var1)
 
USER>d arr.%Push(var2)
 
USER>w arr.%ToJSON()
[123,"123"] //first value is output without quotes, second value is quoted

 

Last answer 9 December 2016
0 2
0

comments

258

views

+ 1

rating

I'm working on a REST service which will include a binary stream as a request property. I'm currently encoding the stream as BASE64 and passing it as a string value, but I was wondering if there is anything in the Caché JSON support that may be a better fit for encoding this data? Thanks Chris

Last answer 7 November 2016 Last comment 14 November 2016
0 0
403

views

+ 1

rating

If you spend a lot of time working with javascript, json and html and you are new to Eclipse / Atelier you may like this tip. 

 Instead of the default Atelier HTML you can install a JS plugin for eclipse which works quite good handling javascript files, allowing you to see functions, color syntax, etc... The one I used is the JSDT. The JavaScript Development Tools (JSDT) provide plug-ins that implement an IDE supporting the development of JavaScript applications and JavaScript within web applications. It adds a JavaScript project type and perspective to the Eclipse Workbench as well as a number of views, editors, wizards, and builders

0 2
0

comments

285

views

+ 2

rating

My organization has been tasked with parsing raw EDI 271 messages into JSON strings in order to feed a downstream application.  A few key details about the task:

  • The raw EDI 271 will be coming across as a standard format from a single outbound upstream system
  • The EDI 271 messages adhere to the 5010 standard
  • We do not need EVERY field from the EDI message, only a select number of fields.  However some of the fields we need (e.g. coverage details) are dynamic in size and will be variable in # of segments both on the EDI side as well as the receiving JSON side.
  • We will be looking to build one incoming business operation for the stream of 271 messages which will then be parsed into Medicare and non-Medicare
  • The JSON output has a static format per class of payor (sample can be referenced below for both Medicare and non-Medicare payors):

Medicare Example JSON

Last comment 18 October 2016
0 0
0

answers

1171

views

+ 1

rating

One useful feature of our REST framework is the ability for a dispatch class to identify request prefixes and forward them to another dispatch class. This approach of modularizing your URL map will improve code readability, enable you to easily maintain separate versions of an interface, and provide a means to protect API calls that only certain users will be allowed to access.

Overview

To set up a REST Service on your Caché instance, you need to define a dedicated CSP application and create the associated dispatch class that handles incoming requests. The dispatch class extends %CSP.REST and will include an XData block that contains your URL map. This tells the system which method to call when a particular request is received.

For example

0 2
0

comments

1420

views

+ 7

rating

Background

Caché 2016.1 introduced some very powerful JSON features.  Unfortunately, the syntax used in the 2016.1 release is going to be changed in the 2016.2 release to bring it closer to Caché ObjectScript syntax.  This will mean that code that works in 2016.1 may not be forwards compatible.   See this announcement and this article for more details about the changes.

In order to try to minimize the volume of code which would not work in future Caché versions, the following recommendations and tools are being used internally within InterSystems for internal application JSON code being written in 2016.1.

Last comment 6 October 2016
0 6
1236

views

+ 9

rating

Hi all,

We're creating a series of RESTful APIs that output data from a Cache database (made up of global storage that we've mapped to classes). I'm running into some problems with object-to-JSON conversions when relationships are involved. Eg:

ParentClass has children relationship to ChildClass

ChildClass has parent relationship to ParentClass

If you %WriteJSONFromObject on an instance of ChildClass, it will retrieve the instance of ChildClass you're asking for, and it will retrieve the ParentClass as a JSON sub object, via the parent relationship (this part is OK), AND it will retrieve EVERY other instance of ChildClass as sub-sub objects, via the children relationship of ParentClass (not OK).

I totally understand why it is doing this, as it's simply retrieving every related object, but for our database this ends up retrieving almost every instance of a given object, and more, when you're only asking for one!

What to do? Here's my thoughts

Last answer 29 September 2016
0 1
0

comments

304

views

0

rating

This is a detailed guide to develop RESTful services using InterSystems Ensemble. The goal of this guide is to make you understanding the basic concept and building blocks of a RESTful service. The service is going to provide a very basic functionality (a “Hello world!”).

You will learn how to create required components as Ensemble classes, configure the run-time as an Ensemble Production and create a service configuration as a web application

0 4
0

comments

1028

views

+ 3

rating

A beginners guide to develop Ensemble RESTful web services.

Background

Before you start reading this short introduction please go through the on-line documentation of Ensemble with special attention to chapter “Creating REST services and clients with Ensemble”.

The approach in the documentation is undisputable the fastest and easiest way to create RESTful services. As a beginner I went through the documentation and I had several questions. This short article is listing those questions plus my humble answers.

When I refer to documentation I mean Ensemble 2016.2 and onwards

Last comment 22 September 2016
0 7
1274

views

+ 9

rating

Hi, all.
I have CSP application and it needs to get and process data from ajax request with json-content. JSON can be very big.
In this case:
TRY
{
Set RequestObj = ##class(%Object).$fromJSON(%request.Content.Read())
} CATCH(Exception) {
Set Status=Exception.AsStatus()
}
I get just part of getting JSON and validate error in $fromJSON.
If I try to read it all in cycle:
TRY
{
While (%request.Content.AtEnd = 0) {
Set Data=Data_%request.Content.Read()
}
Set RequestObj = ##class(%Object).$fromJSON(Data)
} CATCH(Exception) {
Set Status=Exception.AsStatus()
}
I get error.
Increasing of MaxLocalLengt isn't solution.
Is there some good way parse big JSON?

Last answer 22 August 2016 Last comment 25 August 2016
0 1
553

views

0

rating

Today I'm releasing a new EWD 3 module - ewd-feder8.

ewd-feder8 is a federation or integration platform, built as an extension of the EWD 3 ewd-xpress module.  So what does it do and what's it for? 

It's all about federating and integrating multiple web or REST service end-points.

At its simplest you can use it as a proxy server in front of a remote web service or REST end-point.

More usefully, you can send an HTTP or REST request to ewd-feder8, which can then forward it to every member of a group of web service or REST end-point servers.  The responses from the servers are automatically combined by ewd-feder8 to create a composite response which is then returned to the client that sent the original request to ewd-feder8.

Even more usefully, you can customise ewd-feder8 by adding event handlers to

0 0
0

comments

161

views

+ 2

rating

In this article I'll describe how to set up web services and/or REST services using EWD 3.

Since EWD 3 is designed to be modular, you can construct the environment that exactly meets your needs, but for much of the time you'll probably find that the pre-built EWD 3 ewd-xpress super-module does most of what you need because it hooks together all the core EWD 3 and other building-blocks you'll need

Last comment 23 June 2016
0 2
862

views

+ 4

rating

As Rob explained in an earlier post, Caché's Node.js interface allows you to create Web Services and REST Services using the very modular EWD 3 framework.

These services by default return a JSON response with Content-Type: application/json and the response body contains the JSON you return using the finished() method, so:

finished({ test: 'test response' });

returns

{ "test": "test response" }

with a HTTP content-type of application/jso

0 1
0

comments

2103

views

+ 1

rating

Job Description
Caché Objects Web Developer


 

An excellent opportunity exists for an enthusiastic Caché Objects full stack web developer to join our rapidly growing company based near Old Street.

The Job

Our customers use our software to manage events, from small meetings to high-profile conferences and shows. The quality of our software is critical to their success, and critical to our business

0 1
0

comments

256

views

+ 1

rating

Hi,

 

I am trying to use data transformation (DTL) to map a JSON to SDA. My elements in the source JSON is not one to one with SDA object. That means I have to add code to loop through these objects in order to complete the mapping. Can someone send me a sample that can look to create that? I am not very comfortable with scripting language used in Health Share. Appreciate your help.

 

Regards

Joseph

Last answer 16 June 2016 Last comment 16 June 2016
0 1
289

views

0

rating