Commit Graph

262 Commits

Author SHA1 Message Date
tidwall 0cbc0f402f Accept NaN/Inf
This commit allows for NaN and Inf numbers.

see #242
2021-10-22 04:00:22 -07:00
tidwall 35fa0d71c8 Added @keys and @values modifiers
The "@keys" and "@values" modifiers converts an object into an
array of its keys or values respectively.

Take this json for example:

{"first":"Tom","last":"Smith"}

@keys   -> ["first","last"]
@values -> ["Tom","Smith"]

This feature was requested in #161.
2021-10-20 16:31:29 -07:00
tidwall 4fe1916c56 The Array method should return back one item for JSON objects.
This commit fixes an issue where the Array method was not
returning single value arrays when the reciever Result was a
JSON Object.

fixes #240
2021-10-12 10:52:30 -07:00
tidwall 77a57fda87 Limit the complexity of "like" queries that match on a pattern.
This commit adds the uses the MatchLimit function, which it the
same as Match but will limit the complexity of the input pattern.
This is to avoid long running matches, specifically to avoid ReDos
attacks from arbritary inputs.
2021-10-08 07:42:49 -07:00
tidwall 590010fdac Update match dependency
This commit updates the github.com/tidwall/match library, which
address an issue where it's possible to produce a ReDos attack.

fixes #236
2021-10-04 11:46:58 -07:00
tidwall 61273bfa66 Update dependency 2021-09-15 05:37:28 -07:00
Josh Baker 78289be4ed
Create FUNDING.yml 2021-09-07 05:54:48 -07:00
tidwall 75046d2a7a Update comments 2021-09-01 07:33:46 -07:00
Josh Baker 5827eb3b24
Merge pull request #226 from ifraixedes/if/fix-doc-map-method
Fix Map method documentation
2021-09-01 07:27:29 -07:00
tidwall 807836a222 Minor update 2021-09-01 07:25:06 -07:00
tidwall 44b8c19d87 Minor update to test 2021-09-01 07:24:15 -07:00
tidwall 160fb9d6a1 Updated comments 2021-09-01 07:24:00 -07:00
Josh Baker 52919fa7b0
Merge pull request #222 from sspaink/arrayindex
Add support to return multiple indexes when multiple matches are found
2021-09-01 07:17:47 -07:00
Ivan Fraixedes 21a77fab7d
Fix Map method documentation
Fix a typo in the Map method documentation and describes what it returns
when the value isn't JSON to look like the Array method documentation.
2021-07-19 10:56:18 +02:00
Sebastian Spaink 7405f21134 Rename to indexes
Set to nil when modifiers used
2021-07-09 18:15:56 -05:00
Josh a5e52e5b06
Merge pull request #225 from MicahParks/master
Quick typo
2021-07-07 07:06:43 -07:00
Micah Parks d3daff0185 Quick typo. 2021-07-06 21:52:23 -04:00
Bas 7460ecfe69 Fix test 2021-07-01 06:00:44 -05:00
Bas 9b49f6eef5 Undo unnecessary change 2021-07-01 05:58:26 -05:00
Bas 73b86a9fc9 Support queries 2021-07-01 05:58:24 -05:00
Sebastian Spaink 34ea511746 Support getting index for hastags 2021-07-01 05:57:36 -05:00
tidwall 2feb4037b4 Fix escaped strings missing double quote
fixes #223
2021-06-30 13:18:28 -07:00
tidwall ca5c4b1e26 Update SYNTAX.md 2021-05-14 09:08:32 -07:00
tidwall 7a0721334f Fix syntax 2021-05-14 09:02:12 -07:00
tidwall 3c11634522 Update SYNTAX.md 2021-05-14 08:58:36 -07:00
tidwall d7dbdd1d92 Add tilde boolean operator
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"
2021-05-14 08:53:58 -07:00
Josh Baker 51e0e24a13
Delete file 2021-05-12 12:38:01 -07:00
tidwall d9710733f0 Allow escaped string characters in query values
Fixes #215
2021-04-19 09:43:16 -07:00
tidwall d6d786db3c Remove dead code 2021-04-19 09:18:03 -07:00
tidwall 8ac92b3ad3 Remove unreachable code 2021-04-19 09:13:24 -07:00
Josh Baker f3ac38cbb5
Update README.md 2021-04-12 12:41:48 -07:00
Josh Baker 7dde6ac0f6
Merge pull request #211 from realzhili/fix-readme
Update README.md
2021-04-02 07:47:40 -07:00
Zhili Zhang 0301407223 Update README.md 2021-04-01 19:03:29 -07:00
tidwall dee0375ffd Fix negative without int part for valid
fixes #210
2021-03-28 18:30:25 -07:00
Josh Baker 15a2428bae
Create FUNDING.yml 2021-03-28 08:59:52 -07:00
Josh Baker 9e749076bf
Update README.md 2021-03-27 13:24:45 -07:00
Josh Baker 68c884f545
Update SYNTAX.md 2021-03-27 12:06:30 -07:00
Josh Baker e78ccfebe4
Update SYNTAX.md 2021-03-27 12:05:13 -07:00
tidwall d6cb589fc4 Fix non-existent response from multires query on empty array
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 `[]`.
2021-03-25 15:31:00 -07:00
tidwall c75c954102 Fix mod flatten including non-existent arrays 2021-03-25 08:28:15 -07:00
Josh b61527bf1a
Merge pull request #209 from zepatrik/bump-pretty
Bump pretty dependency
2021-03-22 13:05:50 -07:00
zepatrik 2d7fa902d3
Bump pretty
especially to include c41759c9c4
2021-03-22 20:09:24 +01:00
tidwall d18e16d152 Allow chaining multipaths using the dot 2021-03-22 04:19:47 -07:00
Josh 7419d01876
Update README.md 2021-03-05 08:23:41 -07:00
Josh Baker b977acbb8b
Merge pull request #203 from rkilingr/documentation/json-integers
Creates a constant for maximum and minimum JSON Integers and documents them
2021-02-15 12:27:48 -07:00
RaviKiran Kilingar 59f8f07cff
Documents the integer constants used in safeInt and provides links 2021-02-15 23:29:11 +05:30
tidwall 65353b6d52 Removed reflect package
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.
2021-01-30 12:50:49 -07:00
tidwall 97ec619cbe Restrict pretty indent and prefixes to whitespace 2020-12-25 06:42:20 -07:00
tidwall bf4efcb3c1 Fix slice out of bounds panic
fixes #196
2020-12-24 09:51:53 -07:00
tidwall 9f58baa7a6 Update the match package
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
2020-12-23 05:00:23 -07:00