Skip to content

No rels leads to empty array rather than empty object in output #29

Closed
@tommorris

Description

@tommorris

This is probably unfixable because of PHP, but I wanted to file it so it is on record.

If you parse a document that has no rels, you get back an empty JSON array in the json_encoded output. If you parse a document that has rels, you get back a JSON object. The specification says you should get back an empty object.

Obviously, in PHP lists and dictionaries (in Python terminology) are unified into array which can represent both list-style arrays (numerically-keyed arrays in PHP), dictionary-style arrays (associative arrays) and mixed list and dictionary style. json_encode lets you specify a flag for how you encode empty arrays.

One possible solution to this is to json_encode each piece separately and then stitch them together. Or just ignore the problem and operate on the basis that PHP will never quite be spec-compliant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions