Skip to content

Instantly share code, notes, and snippets.

@alejandrobernardis
Created April 30, 2014 23:18
Show Gist options
  • Save alejandrobernardis/67003c983625edf2c681 to your computer and use it in GitHub Desktop.
Save alejandrobernardis/67003c983625edf2c681 to your computer and use it in GitHub Desktop.
Apple, InApp Purchase, Json Sanitize
# Thanks Martijn Pieters => http://stackoverflow.com/a/11242838/3161405
import re
import json
APPLE_SANITIZE = re.compile(r'("[^"]*")\s*=\s*("[^"]*");')
APPLE_SANITIZE_COMMA = re.compile(r',(\s*})')
def apple_json_sanitize(value):
return json.loads(
APPLE_SANITIZE_COMMA.sub(
r'\1', APPLE_SANITIZE.sub(
r'\1: \2,', value
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment