OI10 RTI_JSON (OpenInsight 64-bit)
At 20 APR 2020 01:36:03PM Mihyar Al Masalma wrote:
Hello everyone,
I have noticed a change in OI10 when it comes to RTI_JSON:
assume that we have the following object:
{"entries": [ {".tag": "file","size": 39452,"is_downloadable": true}, {".tag": "file","size": 14371,"is_downloadable": true}]}using the following code we used to get a handler but now we're getting a stringified version:
oEntries = RTI_JSON(oRec, 'GetValue', "entries")now let's parse that array and try to get the count
Entries = RTI_JSON(oEntries, 'GetProperties')this used to return an @FM list of array elements index when oEntries is an array, now in OI10 it just returns "length".
also when try to use
cnt = Rti_JSON(oEntries, 'getValue', 'length')this will return empty
any idea what change need to be done
At 20 APR 2020 02:49PM bob carten wrote:
Hi Mihyar,
We re-wrote RTI_JSON for OI1O. It is C-based rather than OLE. Much faster, but the syntax is a little different I'll make you a working example
- Bob
At 20 APR 2020 03:31PM bob carten wrote:
Json = '{"entries": [' Json := '{".tag": "file","size": 39452,"is_downloadable": true};' Json := ',{".tag": "file","size": 14371,"is_downloadable": true}' Json := ']' Json := '}'The json is not valid. I modified it by removing the '.' and ';'
Json = '{"entries": ' Json := '[' Json := '{"tag": "file","size": 39452,"is_downloadable": true},' Json := '{"tag": "file","size": 14371,"is_downloadable": true}' Json := ']' Json := '}'
// Parse the JSON - oJson will be the handle - it will be a number, not an <idispatch> Declare Function rti_json oJson = rti_json( json, 'Parse') // Use the 'GetObject' call to get the entries object - it too will be a hanlde, a number not an <idispatch> oEntries = RTI_JSON(oJson, 'GetObject', "entries") // Use the getLength to get the length cnt = Rti_JSON(oEntries, 'getlength') // returns '2' because the array has 2 items //now let's parse that array and try to get the count For i = 1 To cnt * Array index is zero based, so use i-1 obji = RTI_JSON(oEntries, 'GetObject', i-1) // This gets the fm delimited list of properties propsi = RTI_JSON(obji, 'GetProperties', i-1) // This gets the value for each property pCnt = fieldCount(propsI, @fm) For j = 1 To pCnt this_prop = propsI<j> this_val = RTI_JSON(obji, 'GetValue', this_prop) Next Next
At 21 APR 2020 12:27AM Donald Bakke wrote:
The json is not valid. I modified it by removing the '.' and ';'
Hi Bob - Where did you see a semi-colon in the original JSON? Also, why is a "." in the JSON Key invalid? I know that "." characters can interfere with certain libraries that reserve it for object purposes, but as far as I can tell it confirms to all JSON specifications.