While trying to strip out the white spaces using libjson function json_strip_white_space() from json string i have observed that the characters after the forward slashes are being striped out so becuse of this the valid json string resulting into a invalid string. Below is the example string:
Input for the json_strip_white_space():
[
{
"NAME" : "KANTESH",
"SNAME" : "NAGARADDER",
"MSG1" : "\"HELLO:HOW ARE YOU\"\n",
"MSG2" : "\"HELLO:///HOW ARE YOU\"\n",
"ID" : 20074499
}
]
Resuting string : [{"NAME":"KANTESH","SNAME":"NAGARADDER","MSG1":"\"HELLO:HOW ARE YOU\"\n","MSG2":"\"HELLO:"ID":20074499}]
In the above resulting string the characters after "///" are being stripped out and concatenated with next line.
I assumed that the jsons_strip_white_space() function treats forward slashes as comments, and i enabled the JSON_STRICT option inorder to escape forward slashes. after enabling the JSON_STRICT option all libjson functions started asking wchar_t* (UNICODE) string as input.
so i converted my json string to unicode and passed to json_strip_white_space() and the string returned from json_strip_white_space() is valid.
Below are few queries :
1) Is my assumtipon i.e json tretas forwards slashes as comment line is correct ?
2) what is the impact of JSON_STRICT option
3) what is the impact of passing wchar_t* after enabling the JSON_STRICT
4) what is the impact of using UNICODE characters than multibyte in JSON
5) Is there any other ways to remove white spaces without enabling the JSON_STRICT option.
Thanks,
Kantesh
Last edit: Kantesh Nagaradder 2015-12-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
While trying to strip out the white spaces using libjson function json_strip_white_space() from json string i have observed that the characters after the forward slashes are being striped out so becuse of this the valid json string resulting into a invalid string. Below is the example string:
Input for the json_strip_white_space():
[
{
"NAME" : "KANTESH",
"SNAME" : "NAGARADDER",
"MSG1" : "\"HELLO:HOW ARE YOU\"\n",
"MSG2" : "\"HELLO:///HOW ARE YOU\"\n",
"ID" : 20074499
}
]
Resuting string :
[{"NAME":"KANTESH","SNAME":"NAGARADDER","MSG1":"\"HELLO:HOW ARE YOU\"\n","MSG2":"\"HELLO:"ID":20074499}]
In the above resulting string the characters after "///" are being stripped out and concatenated with next line.
I assumed that the jsons_strip_white_space() function treats forward slashes as comments, and i enabled the JSON_STRICT option inorder to escape forward slashes. after enabling the JSON_STRICT option all libjson functions started asking wchar_t* (UNICODE) string as input.
so i converted my json string to unicode and passed to json_strip_white_space() and the string returned from json_strip_white_space() is valid.
Below are few queries :
1) Is my assumtipon i.e json tretas forwards slashes as comment line is correct ?
2) what is the impact of JSON_STRICT option
3) what is the impact of passing wchar_t* after enabling the JSON_STRICT
4) what is the impact of using UNICODE characters than multibyte in JSON
5) Is there any other ways to remove white spaces without enabling the JSON_STRICT option.
Thanks,
Kantesh
Last edit: Kantesh Nagaradder 2015-12-14