PList to JSON converter and processing JSON respon

2019-02-11 10:17发布

Is there any tool which can convert my PLIST into JSON. I do not have much idea on JSON formatting. I have a PLIST for which I want an equivalent JSON file.

Also, how do we process JSON response on iOS client using objective C. I have worked with PList response so far.

2条回答
Explosion°爆炸
2楼-- · 2019-02-11 10:28

The best way to do this (on os x) is to use a command line tool, plutil.

It's used like this:

plutil -convert xml1 filenameToConvert -o outputFilename

These are the options for after '-convert': xml1, binary1,json. For this we'll use json. For this command you'll have to be in the same directory as the plist file. For this test we'll convert test.plist (an xml file created by xcode in xml format) into json. It will create a file named test.json:

plutil -convert json test.plist -o test.json

to convert it back we'd go:

plutil -convert xml1 test.json -o test.plist
查看更多
Evening l夕情丶
3楼-- · 2019-02-11 10:29

Others have previously asked about converting .plist files to json here.

Once you have your data in a json format, you can then use Apple's NSJSONSerialization class, documented here:

You use the NSJSONSerialization class to convert JSON to Foundation objects and convert Foundation objects to JSON.

There are other libraries you can use, though, some of which you will find in the answers to this question.

查看更多
登录 后发表回答