Convert JSON to .plist

soleil picture soleil · Nov 14, 2012 · Viewed 18.1k times · Source

I have a JSON file that I exported from a web service. I need to convert this to a .plist file that I can import into the main bundle of an iOS app. What's the easiest way to do this?

Note - the app doesn't need to grab the JSON from a server or anything. This is a one-time conversion that I need to do. The app will always just use the plist. I just need to know how to convert it.

Answer

David Hodge picture David Hodge · Jan 1, 2013

I'd recommend plutil on the command line.

plutil -convert xml1 in.json -o out.plist

It will blow up with NULL values in dictionaries and some other inconsistencies that iOS JSON deserialization will handle more gracefully, but it does appear to work pretty well.