javajsondeserializationjson-deserializationfasterxml

customized JSON parser with equal sign


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?


Solution

  • 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.