Skip to content

support for json as a way to store attributes and metadata #111

@mivanit

Description

@mivanit

yaml is a great format, and human readable, but is difficult to write a parser for, it would be very useful to be able to emit the attributes and metadata as json instead.

My need for this is because I am switching from HDF5 to exdir in a project of mine that uses both C++ and python, primarily because HDF5 is rather difficult to build in C++. The only up-to-date YAML library is unfortunately also rather complicated to build. In contrast, there are minimal header-only libraries for reading both .json and .npy files for C++. I am sure there are a number of other languages it might be easier to make exdir libraries for if json was an option.

Since exdir does not (to my knowledge) directly use the features differentiating YAML from JSON (comments, anchors/aliases, tags) it seems fairly easy to just replace the appropriate methods with those from the json module in the standard library.

I've created a quick and dirty implementation here: https://github.com/knc-neural-calculus/exdir/tree/json-metadata-attrs

Currently, the utils.serialize.MODE variable must be modified and then utils.serialize.refresh() called for json to be used, which is a very messy way to do it. I have not yet updated the tests, but it works fairly well for my current project. If this feature is something worth including in exdir, I would be more than happy to adjust my implementation to make it suitable for inclusion

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