-1

I am writing parsing a JSON Strings and splitting them with a comma, but the Free also contains commas.I am unable to get my Pattern working for this. Tried various combinations but could not succeed. I am using this as part of the Spark streaming, I could not use the JSON parsers for the reason these data come randomly from 750+ random sources, so splitting and getting the text as key-value pairs was a reason to use splitting.

here is my String(Shortened for Stackoverflow use and readability).

            
{"Id":"1","Name":"Celtic,Manor Resort",**"Name":"Hotel Vila Gale Marina, Millennium Golf Course"**}
Code
=============
,(?=(?:(?:[^\"]*+\"){2})*+[^\"]*+$)

Can someone throw some help on this, please!

RamRapolu
  • 1
  • 5

1 Answers1

0

This answer appears to have a valid regex for parsing JSON:

Java: splitting a comma-separated string but ignoring commas in quotes

,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)
JB567
  • 1