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

Domain Specific Formats #56

Open
laktak opened this issue Aug 22, 2016 · 1 comment
Open

Domain Specific Formats #56

laktak opened this issue Aug 22, 2016 · 1 comment

Comments

@laktak
Copy link
Member

laktak commented Aug 22, 2016

Support for additional types and/or formats has been requested several times (hn/reddit/issues):

I've not added new types in the past to keep the Hjson grammar small and because it's not easy to decide which types to add without blowing up the spec.

A possible solution to this problem could be Hjson's quoteless strings. The following is already possible with the current implementations:

{
  nan: NaN
  posInf: Inf
  negInf: -Inf
  hex: 0xff
  date: 2016-08-22
}

This allows formats that are not known by JSON/Hjson to be added without breaking current tools. Anything unknown will be treated as a string.

By using Domain Specific Formats, that can be selectively enabled by the application, we can allow new formats to be added where they are needed. For example

  • math enables NaN, Infinity and -Infinity (should also support -0)
  • date enables ISO_8601 dates
  • hex enables hex numbers

math and date can output the same format when stringified. hex would revert to decimal (unless the desired format were to be stored with the type).

Other formats can be implemented in the application as required.

@laktak
Copy link
Member Author

laktak commented Sep 19, 2016

The JavaScript, Java and C# implementations were updated with experimental support for DSF.

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

No branches or pull requests

1 participant