Description
@benheller from Plex has been kind enough to reach out about breaking changes in the JSON responses from PMS. In PMS v1.3.x there has was introduced some breaking changes in the PMS responses, which I've been told was an effort to prettify, and make the JSON api a supported feature of PMS.
Quoting @benheller:
A pre-1.3.x response might have looked like this:
{
"_elementType": "MediaContainer",
"_children": [
{
"_elementType": "Hub",
"size": 0,
"_children": []
}
]
}
The same response would now be:
{
"MediaContainer": {
"size": 12,
"Hub": []
}
}
In MOST cases, you can take the _elementType, move it to a top level key (e.g. MediaContainer), and replace _children with its own _elementType (e.g. Hub). That said, the 1.3.0 api changes were inconsistent in places, and on the current release you'll see some keys that do not match the previously reported _elementType properties.
In order to maintain compatibility with both pre- and post-1.3.x versions, the library will need to handle both cases. It may be wise to prioritize XML rather than JSON, which gives you full control over the parsing format via xml2js, so that ALL responses will mimic the "old" style JSON. If a consumer of the library wishes to only support PMS 1.3.x and greater, perhaps you can introduce an option to enable prettified responses?
Initially I agree with Ben on handling both pre / post v1.3.x in this package, so that developers and users of plex-api wouldn't have think about which PMS version they're targeting.
Any thoughts are more than welcome here!
For full disclosure, I cannot work on this for at least or week or two, so any help would be more than welcome.