JSON; parse wrong format

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…

If it’s as-is, then split the string (complete) by LineEnding then parse the items in separate json items.

1 Like

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!