Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert JSON to .plist

Tags:

json

ios

plist

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.

like image 857
soleil Avatar asked Nov 14 '12 18:11

soleil


People also ask

Can you convert JSON to XML?

To convert a JSON document to XML, follow these steps: Select the JSON to XML action from the Tools > JSON Tools menu. Choose or enter the Input URL of the JSON document. Choose the path of the Output file that will contain the resulting XML document.

What is Apple plist?

Apple Property List (PLIST) files are used to store serialized objects. They are mostly used in macOS, iOS, NeXTSTEP, and GNUstep programming frameworks.


3 Answers

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.

like image 101
David Hodge Avatar answered Nov 13 '22 11:11

David Hodge


I wrote an online converter to do this. Please have a try.

http://json2plist.sinaapp.com/

like image 20
Chang Avatar answered Nov 13 '22 13:11

Chang


David's answer works pretty well, but as a Ruby lover I've written a very simple tool to do the same with ruby: https://github.com/javiertoledo/json2plist

like image 2
Javier Toledo Avatar answered Nov 13 '22 11:11

Javier Toledo