Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The JSON output of my project is below, where the single quote becomes '\u0027'
HTML
{   "Jurisdiction Name": "Prince George\u0027s County, MD",
    "Maximum xxxx": "300000"   }

I want to the output like that:
HTML
"Jurisdiction Name": "Prince George's County, MD",

How to do the JSON parse in .Net? Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 19-May-15 16:14pm    
Any problem with that?
—SA
s yu 20-May-15 7:16am    
SA: Thanks for your code. Since my project (a kind of ESRI SOE project) has to use PURE .Net code, I can't use JS.

1 solution

In JavaScript, a single quote inside double-quoted string will be parsed correctly as it is. You can check it up with the following JavaScript:
JavaScript
var s = "123'456"
var js = JSON.stringify(s);
s = JSON.parse(js); // the same, after the roundtrip

Therefore, it should be the case with any valid JSON parser.

For parsing, please see my past answers:
How To Convert object type to C# class object type[^],
how to conver multi level json data to C# Object?[^],
haw to get data from Cloudant (json document)[^],
deseralize a json string array[^].

—SA
 
Share this answer
 
v4
Comments
s yu 20-May-15 8:07am    
To avoid the single quote problem stated above, the single quote in a string is replaced by a similar character but in different Unicode (e.g. ʹ or ʾ ).
Sergey Alexandrovich Kryukov 20-May-15 8:33am    
Wrong. There is no such problem.
—SA
s yu 20-May-15 15:32pm    
I know it is NOT the problem as I original posting. My approach is to display the string rather than to solve the single quote issue. This is only a temp. solution till I find the approach for it.
s yu 20-May-15 15:34pm    
Continue - See the output obtained:
"Jurisdiction Name": "Prince Georgeʹs County, MD"
Sergey Alexandrovich Kryukov 20-May-15 15:54pm    
If you read your own question, you will see that it asks about parsing.
As to "display", there is no such problem either. Just display it. Your "approach" is irrelevant.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900