Created
December 5, 2016 20:08
-
-
Save j-wags/bff1ba89376b03577cea677feab73eea to your computer and use it in GitHub Desktop.
First shot at dict reformatting for AWS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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