JKISoftware/JKI-JSON-Serialization

seems to only deal with perfect set of data, and only singles set of double quotes

Closed this issue · 4 comments

If the data matches a json format, it should still be able to parse right?
I am having an issue where the data I am parsing looks like this when I save it to a file and the jki can't parse it:
{""super"":""fun""}

I suspect you need to escape the inner quotes.

"\"fun\""

Hi Walter,
I'm sorry, I should have taken more care in answering clearly.
Your input string is not a valid JSON string. Some characters need to be escaped because they are interpreted by the serializer/deserializer as delimitation characters.

You can see a list of characters that need to be escaped here.

For example, if your input string is "fun", then the flattened JSON output will be "\"fun\"".
The reverse unflattening operation will return "fun" with the quotes because the slash characters tell the algorithm to not consider the following character as a delimiter.

image

Again, consider these two examples:

image

image

JKSH commented

Hi @wegunterjr, you can check if your JSON string is valid or not by using a tool like https://jsonlint.com/

According to the validator,

  • {""super"":""fun""} is not a valid JSON string; it will not be accepted by JSON parsers.
  • {"\"super\"": "\"fun\""} is a valid JSON string; it will be accepted by JSON parsers.