Rochdi Badis · May 3

Resultset to JSON

Hi Guys,

How do I convert a Query resultset to JSON file ?



Product version: Ensemble 2014.1
0 227
Discussion (4)1
Log in or sign up to continue

You can build a %Library.DynamicObject or a %Library.DynamicArray (both extend the %Library.DynamicAbstractObject class) from the ResultSet and use the %ToJSON method.
To build the object it will be necessary to loop the ResultSet writing line by line.

In Ensemble 2014, which the author indicated in his question, there are no classes %Library.DynamicObject and %Library.DynamicArray

See %ZEN.Auxiliary.jsonSQLProvider:%WriteJSONStreamFromSQL()

Simple example

The contents of the file test.json (UTF8):

{"ID":1,"Date":"04.05.2022","bool":0,"int":30,"str":"Hello Caché"}

Can you go the opposite way?  Bind a JSON object to a %Library.ResultSet?