Comments (11)
Upps sorry, Forgot to escape backslahes in the example above:
the right (failing) example line must be:
const char* msg = "Environment: \npid=13232\nhostname=con-js\nALLUSERSPROFILE=C:\\ProgramData\nAPPDATA=C:\\Users\\js\\AppData\\Roaming";
from parson.
Just a note to say that we're experiencing this issue too. Any string value containing more than one backslash (i.e: test\\
) will cause a crash whereas I believe we would expect the value to be escaped like so: test\\\\
from parson.
Here's some simple code that'll reproduce the issue:
JSON_Value *root_value = json_value_init_object();
JSON_Object *root_object = json_value_get_object(root_value);
char *serialized_string = NULL;
json_object_set_string(root_object, "name", "John \\Smith");
serialized_string = json_serialize_to_string(root_value);
json_free_serialized_string(serialized_string);
json_value_free(root_value);
from parson.
Hi NialG,
I edited the tests a bit and could also reproduce this behavior using gcc.
Without calling json_serialize_to_string it works, but i do get an unescaped value, which looks also wrong to me, as you said.
When calling json_serialize_to_string with backslash values I do get a Segmentaion Fault, as on windows...
from parson.
Hi, thanks for reporting this bug.
I'm working on the solution, however current "" parsing behavior is correct. This is explained here: http://stackoverflow.com/questions/3807537/why-does-the-jquery-json-parser-need-double-escaping-for-backslashes
from parson.
What if the raw input actually needs to be \\
then escaping it to \\\\
is correct?
from parson.
That's good to hear. We actually experienced this crash when trying to serialize a string containing two unescaped backslashes.
Thanks for all of your hardwork. Do you have any idea when we're likely to see a fix?
from parson.
In the following days. But as I said, if you need to specify a windows path in a string in your C code then you must use "\\" instead of "\" (if you want it to be parsed as json).
from parson.
This should be fixed now (0d5ac45)
from parson.
It no longer crashes with the example above
JSON_Value *root_value = json_value_init_object();
JSON_Object *root_object = json_value_get_object(root_value);
char *serialized_string = NULL;
json_object_set_string(root_object, "name", "John \\Smith");
serialized_string = json_serialize_to_string(root_value);
json_free_serialized_string(serialized_string);
json_value_free(root_value);
However serialized_string
is still null. I would expect it to be escaped to \\\\
from parson.
Hi, I've fixed this issue in 4a4cf7d
There's been some confusion, but I shouldn't have been parsing strings when using {set,dotset,replace,append}_string functions. So right now json_object_set_string(root_object, "name", "John \\Smith");
should work (and return JSONSuccess). However json_parse_string("{\"name\":\"John\\ Smith\"}")
shouldn't work, as explained here: #26.
from parson.
Related Issues (20)
- LLVM clang 4.0.3 compliation - "%g is unsupported" HOT 4
- Excess precision for small floating point numbers. HOT 16
- kgabis.github.com/parson returns 404 HOT 1
- Is it possible to add option to ignoring the last comma? HOT 3
- Build using meson HOT 13
- JSON Merge HOT 1
- Question on errors - Get information about what failed HOT 1
- why not check the "processed" in parson.c
- clublog-users.json.zip HOT 1
- scan-build bugs
- Accepting invalid array HOT 1
- EOF not enforced HOT 1
- Completion of error handling
- Improve exception handling
- Segmentation fault after invoking json_object_clear() and json_object_remove() back to back. HOT 1
- What if enclosingn [] is missing? HOT 3
- sprintf hard-deprecated on MacOS prevents compiling HOT 3
- Validate JSON inputs HOT 3
- Unstable memory access conflicts that occur when running on Win7 HOT 2
- json_serialize_to_string_pretty received signal SIGABRT, Aborted. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parson.