Skip to content

Instantly share code, notes, and snippets.

@j-wags
Created December 5, 2016 20:08
Show Gist options
  • Save j-wags/bff1ba89376b03577cea677feab73eea to your computer and use it in GitHub Desktop.
Save j-wags/bff1ba89376b03577cea677feab73eea to your computer and use it in GitHub Desktop.
First shot at dict reformatting for AWS
import re
if __name__ == '__main__':
matching_pattern = ':"(?P<value>[A-Za-z0-9]+)"'
substitution_pattern = ':{"S":"\g<value>"}'
orig_text = '{"id":"1"}'
new_text = re.sub(matching_pattern,
substitution_pattern,
orig_text)
print new_text
orig_text = '{"id":"1", "name":"jeff", "age":"30"}'
new_text = re.sub(matching_pattern,
substitution_pattern,
orig_text)
print new_text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment