Skip to content

Instantly share code, notes, and snippets.

@jamster
Created May 6, 2011 20:39
Show Gist options
  • Select an option

  • Save jamster/959738 to your computer and use it in GitHub Desktop.

Select an option

Save jamster/959738 to your computer and use it in GitHub Desktop.
Cleaning JSON
require 'rubygems'
require 'yajl/json_gem'
require 'pp'
json_string = DATA.read
pp JSON.parse(json_string)
__END__
{"contact": {
"kABPersonEmailProperty": [{"email": "[email protected]","label": "Blah","label_local": "Blah"},
{"email": "[email protected]","label": "_$!<Home>!$_","label_local": "home"}
],
"kABPersonAddressProperty": [{"label": "_$!<Home>!$_","label_local": "home","address": {"Country": "United States","Street": "AD1-L1\nAD1-L2\nAD-ST\nAD-ST2","ZIP": "111111","City": "AD-CITY","CountryCode": "us","State": "AD-ST"}},
{"label": "_$!<Work>!$_","label_local": "work","address": {"Country": "United States","Street": "Wrok 1","CountryCode": "us","City": "wc","State": "ws"}}
],
"kABPersonFirstNameProperty": "John",
"kABPersonLastNameProperty": "User",
"kABPersonMiddleNameProperty": null,
"kABPersonPrefixProperty": null,
"kABPersonSuffixProperty": null,
"kABPersonNicknameProperty": null,
"kABPersonFirstNamePhoneticProperty": null,
"kABPersonLastNamePhoneticProperty": null,
"kABPersonMiddleNamePhoneticProperty": null,
"kABPersonOrganizationProperty": "Company",
"kABPersonJobTitleProperty": null,
"kABPersonBirthdayProperty": "TODO: kABDateTimePropertyType",
"kABPersonNoteProperty": null,
"kABPersonCreationDateProperty": "TODO: kABDateTimePropertyType",
"kABPersonModificationDateProperty": "TODO: kABDateTimePropertyType"
}
}
require 'rubygems'
require 'yajl/json_gem'
require 'pp'
json_string = DATA.read
pp JSON.parse(json_string)
__END__
{"contact": {
"kABPersonEmailProperty": [{"email": "[email protected]","label": "Blah","label_local": "Blah"},
{"email": "[email protected]","label": "_$!<Home>!$_","label_local": "home"}
],
"kABPersonAddressProperty": [{"label": "_$!<Home>!$_","label_local": "home","address": {"Country": "United States","Street": "AD1-L1\nAD1-L2\nAD-ST\nAD-ST2","ZIP": "111111","City": "AD-CITY","CountryCode": "us","State": "AD-ST"}},
{"label": "_$!<Work>!$_","label_local": "work","address": {"Country": "United States","Street": "Wrok 1","CountryCode": "us","City": "wc","State": "ws"}}
],
"kABPersonFirstNameProperty": "John",
"kABPersonLastNameProperty": "User",
"kABPersonMiddleNameProperty": null,
"kABPersonPrefixProperty": null,
"kABPersonSuffixProperty": null,
"kABPersonNicknameProperty": null,
"kABPersonFirstNamePhoneticProperty": null,
"kABPersonLastNamePhoneticProperty": null,
"kABPersonMiddleNamePhoneticProperty": null,
"kABPersonOrganizationProperty": "Company",
"kABPersonJobTitleProperty": null,
"kABPersonBirthdayProperty": "TODO: kABDateTimePropertyType",
"kABPersonNoteProperty": null,
"kABPersonCreationDateProperty": "TODO: kABDateTimePropertyType",
"kABPersonModificationDateProperty": "TODO: kABDateTimePropertyType"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment