Skip to content

Scripts to convert objects to yaml/json ready formats #5165

Open

Description

@profxj

I propose to add two scripts to astropy.utils.data (or a neighboring module)
that convert Python objects into YAML or JSON ready formats. This code
already exists (with tests and documentation) as:

linetools.utils.jsonify
https://github.com/linetools/linetools/blob/master/linetools/utils.py

and

desiutils.io.yamilfy
https://github.com/desihub/desiutil/blob/master/py/desiutil/io.py

I feel this has general use within the astronomical community (quite
possible that similar routines already exist).

Activity

  1. pllim commented on Oct 30, 2019

    @pllim
    Member

    Fast forward to 2019, we already have JSON support for a number of objects:

    class JsonCustomEncoder(json.JSONEncoder):
    """Support for data types that JSON default encoder
    does not do.
    This includes:
    * Numpy array or number
    * Complex number
    * Set
    * Bytes
    * astropy.UnitBase
    * astropy.Quantity

    Is there something in particular that is still missing that you think would benefit the astronomy Python community?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions