Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp .net with JSON string

Posted on 2011-02-13
5
Medium Priority
?
666 Views
Last Modified: 2012-06-21
Hi -

I have a string that is stored in the format of JSON
i.e {"comment": "Hello this is a comment"}
I grad the string on the server and send it to jquery to parse.
Everything works great until a someone make a comment like this...
- Hello this is a *comment* - i say "this is fun"
This really messes with my JSON string on the front end

Is there a simple way to encode a JSON string?

Thanks

0
Comment
Question by:doctor069
  • 3
  • 2
5 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 1500 total points
ID: 34883277
You need to escape char like the double quotes : Hello this is a *comment* - i say \"this is fun\"

Check the string section here : http://json.org/
0
 

Author Comment

by:doctor069
ID: 34883293
Thanks but I am not using the NetJSON library on asp .net doesn't Microsoft  have a built in encoder?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34883309
>Thanks but I am not using the NetJSON

why << but >> ?

you need to put a backslash for each reserved character for example with replace : http://msdn.microsoft.com/en-us/library/fk49wtc1.aspx

http://www.apacheserver.net/q25415/Replace-double-quotes-in-json-string-with-empty-string 
0
 

Author Comment

by:doctor069
ID: 34883456
Downloaded Newtonsoft.Json.Net20.dll and I am using:

Json.JsonConvert.SerializeObject(mystring)

Everything seems to work unless I have a word like don't or shouldn't

I thought SerializeObject would handle the ' an I missing something?
 
0
 

Author Closing Comment

by:doctor069
ID: 34884984
a little short in the solution
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question