Hi all,
one of our data analysts has asked for an output of data in NDJSON format - this was a new one to me. Apparently this is 'New line Delimited JSON'. The spec can be found here: https://github.com/ndjson/ndjson-spec
Data is a straight output from an SQL database and it shouldn't be an issue to export as JSON - but not sure in real terms how that would be different from NDJSON... is there a difference?
Many thanks
Stam
NDJSON?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 2
- Joined: Mon Jan 16, 2023 5:50 pm
Re: NDJSON?
Hello everyone
From what I can understand, the NDJSON consists of one JSON for each line. So you can create a couple of functions using JSONtoArray and ArrayToJSON.
From what I can understand, the NDJSON consists of one JSON for each line. So you can create a couple of functions using JSONtoArray and ArrayToJSON.
Code: Select all
-- NDJSONtoArray
function NDJSONtoArray pNDJSON
local tIndex = 0, tArray
repeat for each line tJSON in pNDJSON
add 1 to tIndex
put JSONtoArray(tJSON ) into tArray[tIndex]
end repeat
return tArray
end NDJSONtoArray
-- ArrayToNDJSON
function ArrayToNDJSON pArray
local tIndex = 0, tNDJSON
repeat for each element tArray in pArray
put ArrayToJson(tArray) & cr after tNDJSON
end repeat
return tNDJSON
end ArrayToNDJSON
Re: NDJSON?
thanks @livecode-atc I'll give that a whirl and see if that satisfies our data analysts. Predictably their next best choice was 'CSV' - Big sigh...livecode-atc wrote: ↑Tue Feb 28, 2023 4:37 pmHello everyone
From what I can understand, the NDJSON consists of one JSON for each line. So you can create a couple of functions using JSONtoArray and ArrayToJSON.
(I still don't understand why 90% of the IT world rely on this sh***y format). I'm tempted to just email them all the link to Richard's article https://www.fourthworld.com/embassy/art ... t-die.html but have to rely on their good will for now...
thanks once again,
Stam