facelessuser / SerializedDataConverter

Convert between serialized data formats (plist | json | yaml)
Other
26 stars 4 forks source link

Doesn't work with iOS user defaults plist file #8

Closed revolter closed 9 years ago

revolter commented 9 years ago

Whenever I try to convert from PLIST to JSON I get this in the console:

error: Could not read view buffer as PLIST!
Please see console for more info.
Serialized Data Converter:
Traceback (most recent call last):
  File "plist_json in /Users/Iulian/Library/Application Support/Sublime Text 3/Installed Packages/SerializedDataConverter.sublime-package", line 48, in read_buffer
  File "lib.plist_includes in /Users/Iulian/Library/Application Support/Sublime Text 3/Installed Packages/SerializedDataConverter.sublime-package", line 17, in <lambda>
  File "./plistlib.py", line 104, in readPlistFromBytes
  File "./plistlib.py", line 76, in readPlist
  File "./plistlib.py", line 378, in parse
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 9

The plist file content starts with:

bplist00ß)

if it helps you.

facelessuser commented 9 years ago

I will need an example plist if I am to resolve this. Can you provide one?

facelessuser commented 9 years ago

If what you are using is a binary form of the plist, this does not currently support binary format, just XML. If this is the case, then this is not a bug, but a feature request.

I could add a call to the an OSX native tool that can parse the binary to XML, but it would only be OSX dependent and would not work on Windows or Linux. I would have to write my own binary plist parser or find a python library to do it if I planned on supporting other platforms (not sure if I would go that far).

facelessuser commented 9 years ago

Based on a little research, I am guessing you are trying to convert a binary plist opposed to the XML format; see https://discussions.apple.com/thread/499892. So with that info, this is now more a feature request.

revolter commented 9 years ago

Sorry for late reply, it is indeed a binary plist.

facelessuser commented 9 years ago

Okay, I think I can handle this. I have an idea of how to do this.

revolter commented 9 years ago

Good luck! Let me know if you want some help with it, and if I can, I'll happily help you.

facelessuser commented 9 years ago

No worries, it's pretty straight forward. I'm just grabbing the latest plistlib from python 3.4. Just requires very minor modifications to work in sublime's 3.3 python.

facelessuser commented 9 years ago

Tip of master branch should now support binary plists. More testing still needs to be done before I release it though.

Note that when reading a BPLIST (binary PLIST), the encoding must be Hexadecimal or the view must be a file that exists on disk so that the raw, un-encoded data can be acquired as encoding can lose some of the data. The plugin will abort conversion of BPLISTs if the conditions are not met.

revolter commented 9 years ago

Any idea how to install it on OSX without Package Manager?

facelessuser commented 9 years ago

The easiest way is to install the Github app, and then click the Clone in Desktop button on the repo homepage, and then select the Packages folder as the place to clone it. You can also clone the repo from command line if you are familiar with git.

When playing with it, keep in mind that Package Control will no longer keep you up to date if you manually check it out. At any time you should be able to delete it and reinstall via Package Control.

facelessuser commented 9 years ago

New release has BPLIST support.

revolter commented 9 years ago

Sorry, I didn't have time to test it before. But it does work and it will make my life easier, thanks!

facelessuser commented 9 years ago

Glad it's working for you. Turned out to be much easier than I thought.