Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace newline character in JSON NSString
    text
    copied!<p>I am banging my head against a wall and decided to check in with you guys.</p> <p>I have the following JSON Data as a NSString:</p> <pre><code>{ "PATIENTID": "51853", "MSWREFERRAL": " ", "TIMEIN": " ", "PRECAUTIONOTHERNOTE1": " ", "AGE": "70", "SAFETY2": " ", "VISITTYPE": " ", "RAMP": " ", "BANNISTER": " ", "CREATETIMESTAMP": "1308519326", "SAFETY1": " ", "AGENCYNAME": "RESPONSE HOME CARE", "STAIRS": " ", "AGENCYID": "415", "GUID": "845A481E-8F54-4737-9F55-05FD10E3B931", "ASSIST": " ", "EVALDATE": "06/19/2011", "PULMONARY": "NO", "DOB": "01/17/1941", "GENDER": " ", "STATUS": "pending", "SETTING": " ", "CATHETER": "NO", "PRECAUTIONOTHER1": "NO", "RECENTEVENTS": "*test\n*newline", "PTTIME": "", "TYPE": "eval", "PATIENTNAME": "Gloria Gordon", "CARDIAC": "NO", "PRECAUTION": "NO", "VISITNUM": "1", "PRECAUTIONOTHERNOTE2": " ", "SHUNT": "NO", "WB": "NO", "FALL": "NO", "PRECAUTIONOTHER2": "NO", "LIVES": " ", "THERAPIST": "Bernard George KATZ, PT", "PAID": " ", "PASTMEDHX": " " } </code></pre> <p>I need to either remove the /n between *test and *newline or encode it with //n. I have tried everything I can think of and cannot get the string to replace. </p> <p>So far I have tried:</p> <ul> <li><code>replaceOccurrencesOfString:@"\n" withString:@""</code></li> <li><code>stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet</code></li> </ul> <p>It seems like for some reason, the formmating of the JSON is tripping up the NSString methods. More likely I am doing something stupid.</p> <p>I appreciate your help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload