Search code examples
pythonplistujson

Ujson works on MacOS, but doesn't work on Ubuntu


I've cloned a Python project I was working on on MacOS to a new Ubuntu (virtual) machine.

I've managed to get it to run, but the program crashes at the following line:

ujson.dumps(plist_as_file) # crash

The error is:

TypeError: � is not JSON serializable

I have no idea which character that is, nor where it's found. The plist_as_file is a mac *.plist file, opened with this line:

with open(plist_path, 'rb') as plist_as_file:

It might be that git messed something up, but since both MacOS and Ubuntu are Unix based, I don't really see how.

Any ideas?


Solution

  • It turns out that ujson version on MacOS was 1.35, while the one on Linux was 2.0.1. The module was changed for whatever reason and the version 2.0.1 no longer supports serialization of that type.

    However, if I write:

    ujson.dumps(plist_as_file.readlines())
    

    it works. Since I only need it as an unique identifier, I can use this instead.