Anyone working with NDJSON? also called "JSON Lines" or "Newline Delimited JSON"

“Newline Delimited” JSON.

To be honest, I just came across NDJSON while looking through the specs for the FHIR data required for the US Federal Government’s current UDS+ reporting requirements:
https://fhir.org/guides/hrsa/uds-plus/spec.html

A bunch of JSON stuff combined in a single file.
Can skip over/ignore any badly-formed JSON components.

It’s also called JSON Lines
https://jsonlines.org/

I’ve come across it while mucking about with barcode data, but done little with it.

if using the Capesoft stuff then perhaps you could simply split on the line endings using ST then process each line using jFiles.

something along these lines:

st.loadFile(....)
st.lineEndings(st:unix)
st.split('<10>')
st.removeLines()
loop x = 1 to st.records()
  st.setValue(st.getLine(x))
  json.loadString(st)
  ! process json...
end

or maybe it is more complicated than that?

cheers

Geoff R
*edit: added removeLines after split (gets rid of any blank lines)

From my reading of the spec it’s pretty much as Geoff describes.

It’s just a bunch of JSON “documents”, concatenated together using CRLF, or just LF, if you prefer.

When creating the JSON with jFiles just make sure fornatting is off.

And concatenate using StringTheory AddLine, or SaveFile with Append switch.

Thanks, guys. (At least 20 characters’ worth of text to be sure the appreciation is appropriately expressed.)

2 Likes