Reputation: 828
Is it possible to replace double double quotes in case like this ""something"", in json where empty value is possible case("somthingElse":"")?
I tried with str = str.replace( /\""/g, '"' )
, but this one replace the empty value in my json and i get syntax error.
Example: {"name":"name","price":"","job":""Developer""}
Result: {"name":"name","price":","job":"Developer"}
Upvotes: 1
Views: 988
Reputation: 276296
This is impossible to parse, since the grammar is ambiguous and a result can be interpreted in two different ways. If we replace Developer
in your example with a hand crafted value "", "Developer":""
we get:
{"name":"name","price":"","job":"", "Developer":""}
Which means developer is a field. So unless you can guarantee "
does not appear in the string the grammar is ambiguous.
If I had to guess your backend is hand-making JSON, I've yet to see a case where this is preferable to using a serialization library.
Upvotes: 2