JSONata offers conditional expressions and predicates which can be used to select values out of JSON trees.
However, I have not been able to find a way to test the datatype of a JSON value.
For example, given the array:
[null, true, false, 1, 2.3, "a", ["x"], {}, {"y" : "z}]
I only want to pull out the numeric values.
[1, 2.3]
Q: In a JSONata query, how does one test the JSON datatype (null, boolean, number, string, array, object) of a value?
Currently there is no way to do this in JSONata. Worthy of an enhancement request though.
Wow, today discovered this cool JSONata. Here is my try:
http://try.jsonata.org/
[null, true, false, 1, 2.3, "a", ["x"], {}, {"y" : "z"}]
*[$ ~> /^[0-9\.]{1,}$/m]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With