Commit Graph

74 Commits

Author SHA1 Message Date
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
181e11634d
Code typo 2019-02-16 19:21:12 -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
thirstycoda
cced0fa719 Added not like operator support to query 2018-10-28 00:20:01 +01: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
Josh Baker
6d43584b26
mention related projects 2018-02-10 09:10:40 -07:00
Josh Baker
4b8623b9d6
minor edits 2018-02-09 19:51:56 -07:00
Josh Baker
749b396bb9
Update README.md 2018-02-09 16:09:45 -07:00
Josh Baker
077965694f
changed badge color 2018-02-09 16:08:32 -07:00
Josh Baker
b9953e2865
Update README.md 2018-02-09 16:04:47 -07:00
Josh Baker
a2f35b522e Added support for JSON Lines
Added support for JSON Lines (http://jsonlines.org) using the `..` prefix.
Which when specified, treats the multi-lined document as an array.

For example:

```
{"name": "Gilbert", "age": 61}
{"name": "Alexa", "age": 34}
{"name": "May", "age": 57}
{"name": "Deloise", "age": 44}
```

```
..#                   >> 4
..1                   >> {"name": "Alexa", "age": 34}
..3                   >> {"name": "Deloise", "age": 44}
..#.name              >> ["Gilbert","Alexa","May","Deloise"]
..#[name="May"].age   >> 57
```

Closes #60
2018-02-09 15:42:42 -07:00
Josh Baker
bff3f07fe7
mention large integer support 2018-02-08 12:21:08 -07:00
Josh Baker
09641abb33 update tagline 2017-12-22 07:16:29 -07:00
Josh Baker
e62d62a3e1 match GetMany and Get results, fixes #55 2017-12-22 06:58:04 -07:00
Josh Baker
ac7b6ae6f2 deprecated unmarshalling 2017-10-18 05:19:20 -07:00
Josh Baker
4e8f0c7f28 added playground link 2017-08-14 18:16:21 -07:00
Josh Baker
6daf3373dc Moved benchmark code
Moved benchmark to a different repository to avoid the fetching of
unneeded imports. Please find these benchmarks at
https://github.com/tidwall/gjson-benchmarks
2017-08-14 08:21:16 -07:00
Kashav Madan
8eb5c54ee3 Minor README clean-up 2017-05-10 23:42:56 -04:00
Josh Baker
617caec145 Update README.md 2017-05-08 21:47:28 -07:00
Josh Baker
2e78916f4a option to disable validation 2017-05-08 17:47:46 -07:00
Josh Baker
2555fc0b61 Unmarshal Validation
The Unmarshal function now returns an error if the JSON is not valid.
2017-05-08 17:33:03 -07:00
Josh Baker
0bedaf01cb updated wording 2017-05-08 07:47:07 -07:00
Josh Baker
371acf8f0c updated wording 2017-05-08 07:40:56 -07:00
Josh Baker
19194a58d8 typos 2017-05-08 06:55:29 -07:00
Josh Baker
3f5adf1ba9 New gjson.Unmarshal function
It's a drop in replacement for json.Unmarshal and you can typically see
a 3 to 4 times boost in performance without the need for external tools
or generators.

This function works almost identically to json.Unmarshal except that
it expects the json to be well-formed prior to being called. Invalid
json will not panic, but it may return back unexpected results.
Therefore the return value of this function will always be nil.

Another difference is that gjson.Unmarshal will automatically attempt
to convert JSON values to any Go type. For example, the JSON string
"100" or the JSON number 100 can be equally assigned to Go string,
int, byte, uint64, etc. This rule applies to all types.
2017-05-07 18:26:54 -07:00
Josh Baker
039b641eab added result.Time() function 2017-04-14 17:58:25 -07:00
Josh Baker
6e0babc7e8 updated benchmarks, added features list 2017-04-14 11:13:32 -07:00
Josh Baker
a8ccb8767a mention "values" 2017-04-12 14:16:56 -07:00
Josh Baker
7d884e04ac minor update 2017-04-12 14:14:42 -07:00
Josh Baker
766ad13f76 minor updates 2017-04-10 12:26:09 -07:00
Josh Baker
9c689b0be6 cleanup benchmarks 2017-04-10 11:41:37 -07:00
Josh Baker
8f291465f6 added Exists() to the list of handy functions 2017-04-02 10:13:06 -07:00
Josh Baker
09d1c5c5bc added gjson-safe comment 2017-02-05 09:10:42 -07:00
Josh Baker
e3f249f4fd Missing package alias 2016-12-16 09:22:41 -07:00
Josh Baker
1a8de7c426 add query operators 2016-12-02 11:53:14 -07:00
Josh Baker
6fd75099ef Update README.md 2016-11-30 12:04:48 -07:00
Josh Baker
62892351c5 added ForEach function 2016-11-30 10:50:59 -07:00
Josh Baker
86b1b630e4 Query array for multiple matches
It's now possible to query an array for multiple matches by adding the
'#' character immediately following the query.

For example, using the following JSON:

  {
    "friends": [
      {"first": "Dale", "last": "Murphy"},
      {"first": "Roger", "last": "Craig"},
      {"first": "Jane", "last": "Murphy"}
    ]
  }

To return the first match:

  `friends.#[last="Murphy"].first` >> "Dale"

To return all matches:

  `friends.#[last="Murphy"]#.first` >> ["Dale","Jane"]

Thanks to @chuttam for requesting this feature, closes #15.
2016-11-30 07:59:24 -07:00
Josh Baker
1a15b54bbb add bookmark link for GetMany 2016-11-28 19:04:18 -07:00
Josh Baker
ae5d307631 Added GetMany. Query many paths at once.
The `GetMany(json, paths...)` function can be used to get multiple
values at one time from the same json string.
This is preferrable to calling `Get(json, path)` over and over.
It's also optimized to scan over a JSON payload once.

This addresses a feature request by @FZambia, and closes #13.
2016-11-28 15:10:11 -07:00
Josh Baker
72b0cad1c1 example getting raw bytes, closes #12 2016-11-04 19:41:23 -07:00
Josh Baker
ac4cd1ab55 empty arrays for non-existent values #11 2016-11-02 13:45:25 -07:00
Josh Baker
b95abbe94a removed obsolete field 2016-11-02 11:01:06 -07:00
Josh Baker
a02d704254 added result.Uint() function resolves #9 2016-11-02 08:24:13 -07:00
Josh Baker
78babc5712 typo 2016-10-30 14:35:08 -07:00
Josh Baker
bc89b871de typos 2016-10-28 10:56:10 -07:00
Josh Baker
95c6f92c50 mention GetBytes function 2016-10-28 09:07:48 -07:00