0

Taking json from a website and getting some json results back with escaped characters.

What's the best design pattern for removing the characters we don't like?

Here are some we don't like from here:

  • \b Backspace (ascii code 08)
  • \f Form feed (ascii code 0C)
  • \n New line
  • \r Carriage return
  • \t Tab
  • \v Vertical tab
  • \' Apostrophe or single quote
  • \" Double quote
  • \ Backslash character

But my question is, in general, should you do

  1. it before you save it?
  2. after you save it, convert it right away?
  3. or should you convert it right before you display/use it?
Community
  • 1
  • 1
Andrew Chung
  • 417
  • 4
  • 15
  • Use this [NSString + HTML category](http://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m) to remove all. – iDev Dec 07 '12 at 19:42

1 Answers1

0

Remove it right after downloading. It's kinda costly (especially if you use regular expressions), so it'll be done once, and not needed again.

Cyrille
  • 25,014
  • 12
  • 67
  • 90