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

Request: function or functions for testing data type of a value #208

Closed
michaelthoward opened this issue Apr 19, 2018 · 3 comments
Closed

Comments

@michaelthoward
Copy link

Per this question on stackoverflow, JSONata needs a function functions for testing JSON data type.

Seems this could be predicates for testing individual data types (e.g. isBoolean(), isNumber(), etc.) and/or a function which returned the data type as a string.

@basel-shishani
Copy link

+1
I believe this feature is essential as it's very common to have structures with anyOf possible types.

@jhorbulyk
Copy link
Contributor

Proposal for syntax:
$type(value)
Returns:

  • (non-string) undefined if value is undefined
  • (string) 'null' if value is null
  • (string) 'number' if value is a number
  • (string) 'string' if value is a string
  • (string) 'boolean' if value is a boolean
  • (string) 'array' if value is an array
  • (string) 'object' if value is an object
  • (string) 'function' if value is a function

@andrew-coleman
Copy link
Member

Resolved by #381

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

No branches or pull requests

5 participants