What’s the trick to build a JSON string

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

What’s the trick to build a JSON string

Post by Jaymer »

Now that the new build is out, and the REST process will properly send a JSON string, is there a particular strategy or technique that makes building this potentially long string easy?
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Re: What’s the trick to build a JSON string

Post by Rennur »

One option would be to use a query widget type or settings to generate results in JSON, or use a FIND function (query) with a CONVERT_TO_JSON function. Then store the string parameter.

The other, Aware IM to convert XML to JSON then save it in an attribute?

Converting Java objects to JSON with Jackson

XML to JSON Converter
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: What’s the trick to build a JSON string

Post by BenHayat »

Jaymer wrote:Now that the new build is out, and the REST process will properly send a JSON string, is there a particular strategy or technique that makes building this potentially long string easy?
Generally speaking, JSON construction is part of the framework, i.e. AwareIM. In other systems you simply tell the system how your input/output format should be, like XML or JSON and the system does it.
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: What’s the trick to build a JSON string

Post by tford »

Now that the new build is out
Jaymer -- are you referring to build 2465?
Tom - V8.8 build 3137 - MySql / PostGres
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: What’s the trick to build a JSON string

Post by Jaymer »

yes, 2465 fixed this 1 issue with JSON strings
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: What’s the trick to build a JSON string

Post by Jaymer »

Well, since I'm using MS SQL SERVER, I can take advantage of "FOR JSON" on a SELECT statement and it makes pretty JSON for me.
Couldn't be happier.

jaymer...
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
UnionSystems
Posts: 197
Joined: Fri Jun 17, 2016 7:10 am
Location: Brisbane Australia
Contact:

Re: What’s the trick to build a JSON string

Post by UnionSystems »

A trick we have used in AwareIM to get data into a JSON string is

1. Publish an AwareIM REST Service that outputs as JSON
2. Call that Service using the AwareIM’s URL_CONTENTS function to call the local REST request

Code: Select all

Object.JSON_String = URL_CCONTENTS(‘http://localhost:8080/REST SERVICE ADDRESS’)
AWS Linux, Windows Server, AIM 8.4 & 8.6
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Re: What’s the trick to build a JSON string

Post by Rennur »

Kendo UI offers JSON through spreadsheets. I think Aware has the spreadsheet feature.

Store Data as JSON
The Spreadsheet allows you to store and load data in a native JSON format.
https://docs.telerik.com/kendo-ui/controls/data-management/spreadsheet/import-and-export-data/json

Could this be of any use, if so, how?

From the How-to guide (p41):
How to work with embedded spreadsheets
To use embedded spreadsheets in Aware IM you need to do the following:
- Define an attribute of the Document type in some object
Support, if the spreadsheet stores the data in JSON format, could this document attribute be used as a parameter string in context?
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: What’s the trick to build a JSON string

Post by aware_support »

Here is one idea how you can get JSON representation of Aware IM records using the current Aware IM version. This is an idea only, we haven't tested if it works.

1) Define an Aware IM service that is implemented using REST
2) Define the reply of this service to return the object(s) you want converted into JSON
3) Define JSON as the format of the reply. Define name mapping and other JSON conversion parameters as required
4) The process that implements the service should find the instance(s) that you want to convert to JSON and put them in Context
5) Call the service using the URL_CONTENTS function where the URL specified in this function is the URL of the service exposed above
6) The URL_CONTENTS function should return JSON representation of the record(s)

If this doesn't work let us know why and we may fix the problems, so that this approach can be used for JSON conversion
Aware IM Support Team
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: What’s the trick to build a JSON string

Post by Jaymer »

Is anyone going to try Vlad's suggestion?
Since I got my JSON output figured out, I don't have time right now-I'm busy working on other REST issues.
If someone DOES decide to tackle this, please leave a msg here so we don't duplicate effort.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: What’s the trick to build a JSON string

Post by BobK »

Isn't Vlad's suggestion the same as UnionSystems a few post up except with a some more details.
Bob
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: What’s the trick to build a JSON string

Post by aware_support »

Yes, it's the same. Sorry, UnionSystems, didn't see your post (but great minds think alike :) )
Aware IM Support Team
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Re: What’s the trick to build a JSON string

Post by Rennur »

Cannot get steps 5 & 6 to work.

com.bas.shared.ruleparser.ParseException Unable to retrieve contents of the URL due to exception java.io.IOException Server returned HTTP response code: 500 for URL: http://localhost:8081/AwareIM/REST/CR/SI_REST_Service
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: What’s the trick to build a JSON string

Post by Jaymer »

I'm getting Rest 500's now also, per this thread.
https://www.awareim.com/forum/viewtopic.php?f=1&t=10473
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: What’s the trick to build a JSON string

Post by aware_support »

Check out the output of Tomcat and the Aware IM Server for clues.
Aware IM Support Team
Post Reply