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

Proposal: Add support for a wildcard 'any' type #2

Open
davejhilton opened this issue Jun 4, 2018 · 0 comments
Open

Proposal: Add support for a wildcard 'any' type #2

davejhilton opened this issue Jun 4, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@davejhilton
Copy link

This is a proposal for the addition of a "wildcard" type to the JSTN spec.

Adding such a "wildcard" type would essentially allow all JSON documents to be representable by JSTN... albeit with the introduction of some ambiguity in type information.

The proposed type might be represented in the grammar by the string literal any. Its behavior would be that it can be used to declare in a JSTN text that a property is expected in the JSON document, but without making claims about its value's type. The most obvious use-case for this, perhaps, would be to allow JSTN to represent JSON documents that container arrays with items of mixed inner types. e.g.,

{
    "ints": [1, 2, 3],
    "randomStuff": ["dog", 7, null, [], {"hello": "world"}]
}

could at least be representable in JSTN, using the following type declaration:

{
    ints: [int]
    randomStuff: [any]
}

Check out my pull request #1 to see an example of this in action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants