Problems with "\" appearing in iOS development interface

Source: Internet
Author: User

Recently in the project development, due to the background interface problems, there is a "\" such data, according to the general development of JSON data read, will not be recognized, because in the general language "\" are escaped, then the problem, how to solve it?

This problem has plagued me for a long time, first of all, let's look at the Bejson to identify the normal JSON data:

This is the normal JSON data, now add a "\" in the data and then look at:

The error! In fact, if you test with a carriage return, there will be surprises:

Did it fail too? This problem, I have a feeling of collapse, in addition to the use of third-party library, feel, the other will not love again, I think of the solution, usually, some rigid, the method is as follows:

I generally use the download third-party library afnetworking

//json parsing
//NSString *mustr=[[nsmutablestring alloc]
//initwithdata:responseobject encoding:nsutf8stringencoding];//binary converted to string
//mustr=[mustr stringbyreplacingoccurrencesofstring:@ "\ \" withstring:@ ""];//replace the contents of the string inside
//NSLog (@ "%@", mustr);//print a bit
///Responseobject=[nsmutabledata datawithdata:[mustr datausingencoding:nsutf8stringencoding]];//to convert the replaced string into binary, used to parse

This is a lazy (rotten) way, because there are a lot of terminal commands, there will be a backslash, so I personally think, in addition to the background need to do this aspect, that only self-parsing, or, directly skip this message, or,,, find a more mature third-party library is good,

Problems with "\" appearing in iOS development interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.