Objective-C - How to convert NSString to escaped JSON string?
问题 I have a NSString that may contain quotes,\, /, \r, \n, and I want to convert it to a JSON encoded string so strings like this "text1\text2" becomes \"text1\\text2\" Is there a existing function to let me do this? Also, I am using SBJson in my project but I cannot find whether SBJson can do this or not. NSJSONSerialization is not on the table since my application still needs to support OSX 10.6 回答1: Does this answer your question? -(NSString *)JSONString:(NSString *)aString { NSMutableString