I’m using fasterxml java library to parse json data, some of the data is using =
instead of :
as the key value seperator, e.g. {"key"="foo", "size"=123}
, is there a way to let json parser properly parser this kind of data?
Question posted in Json
Our archive of expertly curated questions and answers provides insights and solutions to common problems related to this popular data interchange format. From parsing and manipulating JSON data to integrating it with various programming languages and web services, our archive has got you covered. Start exploring today and take your JSON skills to the next level
Our archive of expertly curated questions and answers provides insights and solutions to common problems related to this popular data interchange format. From parsing and manipulating JSON data to integrating it with various programming languages and web services, our archive has got you covered. Start exploring today and take your JSON skills to the next level
2
Answers
what about replace ‘=’ with ‘:’, then use JSON.parse
string.replace("=",":")
I don’t think that this is a good idea … but you could examine the source code of the fasterxml, find the JSON parser, and modify it to accept
=
as an alternative to:
in the appropriate place.(I took a look at the code for myself, and it is complicated. If I was going to go down this rabbit hole, I’d investigate whether it would be feasible to switch to a simpler JSON parser.)
A better idea would be to fix the software (or process) that is producing this "not JSON" so that it actually produces syntactically correct JSON. The point of standard formats like JSON is to facilitate interoperable systems, software, libraries and so on. When people generate data that doesn’t conform to the standard format, it subverts that goal. They should be told to stop … even if they are your paying customers. They are not doing anyone any favors.