Commit Graph

183 Commits

Author SHA1 Message Date
tidwall 1c258afe09 Allow for modifiers in sub-selectors 2019-11-01 05:08:48 -07:00
tidwall c5e72cdf74 Fix panic when key starts at-sign 2019-07-15 07:54:43 -07:00
tidwall dea71f728d Mention nested queries 2019-07-12 06:46:38 -07:00
tidwall 1e964df7d9 Support subqueries
It's now possible to do a query like

  topology.instances.#(service_roles.#(=="one"))#.service_version

On a JSON document such as

  {
    "topology": {
      "instances": [{
        "service_version": "1.2.3",
        "service_roles": ["one", "two"]
      },{
        "service_version": "1.2.4",
        "service_roles": ["three", "four"]
      },{
        "service_version": "1.2.2",
        "service_roles": ["one"]
      }]
    }
  }

Resulting in

  ["1.2.3","1.2.2"]
2019-07-12 06:14:45 -07:00
Josh Baker 90ca17622f
Update SYNTAX.md 2019-07-10 15:00:07 -07:00
tidwall 4d138e058b Add multipath syntax 2019-06-30 12:59:56 -07:00
tidwall d7c940e593 Fix missing raw result for array counts 2019-06-30 04:48:53 -07:00
tidwall 3b5bf6bb5e Added Subselectors
It now possible to select multiple independent paths and join
their results into a single JSON document.

For example, given the following JSON

    {
      "info": {
        "friends": [
          {"first": "Dale", "last": "Murphy", "age": 44},
          {"first": "Roger", "last": "Craig", "age": 68},
          {"first": "Jane", "last": "Murphy", "age": 47}
        ]
      }
    }

The path `[info.friends.0.first,info.friends.1.last]` returns

    ["Dale","Craig"]

Or path `{info.friends.0.first,info.friends.1.last}` returns

    {"first":"Dale","last":"Craig"}

You can also rename Object members such as

`{"alt1":info.friends.0.first,"alt2":info.friends.1.last}` returns

    {"alt1":"Dale","alt2":"Craig"}

Finally you can combine this with any GJSON component

`info.friends.[0.first,1.age]` returns

    ["Dale",68]

This feature was request by @errashe in issue #113.
2019-06-29 15:23:32 -07:00
tidwall 001444ea45 Remove the DisableChaining option
Chaining (pipe character) is now a part of the standard
2019-06-29 12:10:41 -07:00
tidwall 6781e4ee59 Allow paren queries 2019-06-29 11:31:27 -07:00
tidwall f8322e865d Rename file 2019-06-28 17:18:24 -07:00
Josh Baker f7c1980254
Update README.md 2019-06-28 17:17:38 -07:00
Josh Baker ae482cd23d
Update README.md 2019-06-28 17:16:29 -07:00
Josh Baker f73dd9bfd8
Create PATH-SYNTAX.md 2019-06-28 17:11:56 -07:00
tidwall ebf0b3fb77 Use no path for simple value queries 2019-06-28 10:18:23 -07:00
tidwall 00b15d756e Added querying array values 2019-06-28 05:55:18 -07:00
tidwall d95cbcaa9d Require multiarr results to always exist 2019-06-28 05:24:28 -07:00
tidwall e91a88bec4 Allow for chaining syntax in multi array 2019-06-28 04:41:32 -07:00
tidwall 6eb62ca33f Added new tests for deep selectors 2019-06-27 18:37:09 -07:00
tidwall 7660d0f79f Allow for pipe and dot mixing 2019-06-27 18:27:53 -07:00
tidwall 7b8705a6b6 Use 80 column width 2019-06-27 18:03:46 -07:00
tidwall b877bd43b1 Allow for chaining syntax in array subselects 2019-06-27 17:51:42 -07:00
tidwall 89b19799ff Fix non-existent selectors results 2019-06-27 15:50:15 -07:00
Josh Baker 40764d5d56 Added Go modules support 2019-06-05 16:41:31 -07:00
tidwall fb8e539484 Fixed typo in comment
close #109
2019-04-05 11:08:30 -07:00
Josh Baker 181e11634d
Code typo 2019-02-16 19:21:12 -07:00
tidwall eee0b6226f Fixed chained array result 2019-02-16 19:06:55 -07:00
tidwall 1ed2249f74 Added modifiers and path chaining
A modifier is a path component that performs custom processing on
the json.

Multiple paths can be "chained" together using the pipe character.
This is useful for getting results from a modified query.

See the README file for more information.
2019-02-16 18:29:39 -07:00
tidwall 5d7556ad3d Valid json optimization
Added ~20% performance boost be removing extra allocation when
Valid() is called with a json string.
2019-02-16 14:50:53 -07:00
tidwall 5a96cfda70 Added GopherJS support 2019-01-14 08:40:04 -07:00
Josh Baker 081192fa2e
Merge pull request #98 from thirstycoda/master
Added not like operator support to query
2018-10-28 08:46:04 -07:00
Josh Baker 1bd06b6ad9
Merge pull request #97 from dustinblackman/fix/getmanybytes
Fix GetManyBytes to use byte related methods
2018-10-28 08:42:31 -07:00
thirstycoda cced0fa719 Added not like operator support to query 2018-10-28 00:20:01 +01:00
Dustin Blackman 4c7d6ff4a9
fix GetManyBytes to use byte related methods 2018-10-25 16:34:28 -04:00
tidwall 1e3f6aeaa5 Fix leftover array and map values
fixes #81
2018-08-02 08:58:17 -07:00
Josh Baker f92dbfc6b2 Fix different reuslts on duplicate keys
fixes #79
2018-07-30 14:44:31 -07:00
Josh Baker ba784d767a Fix string output for large integers
This fix makes calling String() on a JSON Number return the original value
as it was represented in the JSON document for signed and unsigned integers.
This ensures that very big (plus-53bit) integers are correctly returned.
Floating points maintain their previous behavior [-+]?[0-9]*\.?[0-9]*.

closes #74
2018-07-10 18:10:33 -07:00
Josh Baker f123b34087 Add appengine support 2018-06-21 11:09:58 -07:00
Josh Baker afaeb95620 Fix false validation
closes #73
2018-06-13 11:46:59 -07:00
Josh Baker 3cd3a11923
Merge pull request #71 from speier/master
valid bytes method
2018-04-29 08:13:28 -07:00
speier 3a977634eb valid bytes method 2018-04-27 15:54:16 +02:00
Josh Baker 9ed3f8e1a5
Merge pull request #67 from bcho/patch-1
Add `arrayOrMap` result description
2018-03-01 11:15:57 -07:00
hbc 93d61e6369
Add `arrayOrMap` result description
Explain `Result.Value` will return array and map when possible.
2018-02-28 11:21:22 +08:00
Josh Baker 01f00f1296
Merge pull request #66 from Hexilee/master
Result.Bool() can parse 'false' as false
2018-02-23 08:48:56 -07:00
Hexilee 9fa9086994 Result.Bool() can parse 'false' as false 2018-02-23 20:25:48 +08:00
Josh Baker aff9dcea3c uncomment function 2018-02-18 10:09:03 -07:00
Josh Baker c2e370e1b3 comment on Valid 2018-02-18 10:05:23 -07:00
Josh Baker df0b0cce42
section on json validation 2018-02-18 09:49:01 -07:00
Josh Baker 46c712f1ce
update playground badge 2018-02-10 11:31:49 -07:00
Josh Baker 54d114d487
minor updates 2018-02-10 09:30:30 -07:00