Skip to content

Instantly share code, notes, and snippets.

@teebot
Created February 6, 2015 09:26
Show Gist options
  • Save teebot/d063f80ba1913a4a40cd to your computer and use it in GitHub Desktop.
Save teebot/d063f80ba1913a4a40cd to your computer and use it in GitHub Desktop.
Regex replace a JSON dictionary by an array of objects
{"BE":"Belgium"}, {"IT":"Italia"}
to
[{ "code": "BE", "name": "Belgium"}, { "code": "IT", "name": "Italia"}]
replace this ([^{},:]*):([^{},:]*)
with this : { "code":$1, "name": $2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment