This commit adds the new tilde '~' operator, which when used will
convert a value to a boolean before comparison.
For example, using the following JSON:
{
"vals": [
{ "a": 1, "b": true },
{ "a": 2, "b": true },
{ "a": 3, "b": false },
{ "a": 4, "b": "0" },
{ "a": 5, "b": 0 },
{ "a": 6, "b": "1" },
{ "a": 7, "b": 1 }
{ "a": 8, "b": "true" },
{ "a": 9, "b": false }
{ "a": 10, "b": null }
{ "a": 11 }
]
}
You can now query for all true(ish) values:
vals.#(b==~true)#
Which returns:
[1,2,6,7,8]
Or all false(ish) values:
vals.#(b==~false)#
Which returns:
[3,4,5,9,10,11]
The last value which was non-existent is treated as "false"
This commit fixes an issue where a multires query on an empty
array will result in a non-existent (empty string) result.
For example `Get("[]", "#(key=value)#").Raw` resulted in an
empty string. But, it should actually result in the empty
array `[]`.
This commit removes the reflect package to avoid using the
reflect.SliceHeader and reflect.StringHeader structures. Instead
new sliceHeader and stringHeader stuctures have been added with
the same layout expect that they intentionally expose the data
field as an unsafe.Pointer instead of a uintptr.
This commit updates the match package to v1.0.3, which includes
a fix to an issue where a pattern with lots of repetitive stars
will increasingly slow down a Match operation.
Fixes#195
golang has several tools that already parse boolean values in the standard library.
Specifically strconv.ParseBool(string)
https://golang.org/pkg/strconv/#ParseBool
"ParseBool returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error."
This change returns any matching ParseBool string to that boolean value, or if the string is not one of those values, the error being thrown, returns a false.