Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON form of table #311

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Add JSON form of table #311

wants to merge 2 commits into from

Conversation

rvagg
Copy link
Member

@rvagg rvagg commented Jan 30, 2023

Closes: #305

Draft for now, just putting it up for initial feedback.

  • one entry per line, but still a valid complete JSON file, so it also has [ and ] lines.
  • padded to make the columns line up
  • "description" column is optional and is dropped where blank
  • added "intcode" and "varint" (hex bytes) fields
  • I also added an optional "ref" column with only the CID ones filled in so far .. I don't think left-padding this column is going to be ideal since "description" can get quite large. An option here is to add a compound object to combine "description" and "ref" and only left-pad the top-level items, "status": "permanent", "notes": { "description": "CIDv1", "ref": [ "https://github.com/multiformats/cid" ] },

What I think should be done to make this complete:

  • Add a script that will compile JSON to CSV, correctly formatted
  • Add a script that will load the CSV and write any updates back into the JSON - which would make for an easier workflow to add new entries where you don't want to have to deal with formatting or adding the intcode or varint entries
  • Add a script that will lint both JSON and CSV and make sure they match, which we can also add to CI
  • A Makefile that will run these scripts easily for any contributor and CI
  • Docs to describe how to consume the data and how to contribute new entries

@rvagg
Copy link
Member Author

rvagg commented Jan 30, 2023

Link to file as you would view it on GitHub: https://github.com/multiformats/multicodec/blob/rvagg/json/table.json

@rvagg rvagg self-assigned this Jan 30, 2023
@rvagg
Copy link
Member Author

rvagg commented Jan 30, 2023

Another alternative is to nest the 3 code values into a nested object: "code": { "hex": "0x78", "int": 120, "varint": "0x78" }. Any nested object doesn't get the padding treatment.

@vmx
Copy link
Member

vmx commented Jan 31, 2023

Either layout is fine, I'd KISS and just have non-nested values. This also makes it easier if you e.g. write your own tooling and you want to convert it quickly to CSV.

@darrylyeo darrylyeo mentioned this pull request Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JSON form of the table
2 participants