I have the following file with JSON data - obviously wrong at root level!
{ "test1":1 }
{ "test2":{"test2.1":"2.1"}}
{ "test3":"3"}
The upper most nodes are concatenated from different sources.
In Editor no problem: let reformat (which btw works) and replace /^\} \{/
by }, {
and put [ ]
around.
Any idea how I can parse this “fault tolerant” alike by program?
Thanks in advance!
Yes, I should force the sender to send correct format… but not so easy as usual…
DerkJ
(DerkJ)
June 23, 2022, 1:55pm
2
If it’s as-is, then split the string (complete) by LineEnding then parse the items in separate json items.
1 Like
Greg_O
(Greg O)
June 23, 2022, 6:23pm
3
You could put commas between them and wrap the whole thing in square brackets.
As I wrote
In Editor no problem: let reformat (which btw works) and replace /^\} \{/
by }, {
and put [ ]
around.
You could put commas between them
“them” are the human visible brackets - well if in one line that would work.
So, I guess this has to be done with a specialized JSON parser.
Thanks a lot for the comments!
First I thought it must be parsed.
But, /}\s*{/
can not exist in JSON so find-replace with , does work:-)
Assuming no key/value contains }{
Greg_O
(Greg O)
June 29, 2022, 12:22pm
6
If they do and they are legal JSON, they would have to be escaped or encoded anyway.