Riccardo Coccioli
Riccardo Coccioli
@litao09h @liveFreeOrCode As far as I know it's not possible to do it for the generic case of arbitrary depths. But if you know in advance the possible depths where...
@Storm-Born as mentioned recently in https://github.com/tidwall/gjson/issues/295#issuecomment-1483809118 you can get a default value in arrays with the `[key,!"default"].0` pattern. So in this case you could do (using `null` as default value,...
@Storm-Born I would just query for `persons` and then check on the code that parses the results if an attribute is missing, but of course that depends what is consuming...
@ngarg-kr you can chain queries for additional fields, so in your case with query: ``` friends.#(first=="Dale")#|#(last=="Murphy")#.age ``` you get: ```json [44] ``` See https://github.com/tidwall/gjson/blob/master/SYNTAX.md#queries and https://github.com/tidwall/gjson/blob/master/SYNTAX.md#dot-vs-pipe for additional information.
@sukant-kr Yes and no, as I've answered in https://github.com/tidwall/gjson/issues/315#issuecomment-1457570374, you can achieve the OR with multipaths and the `@flatten` modifier, but it would not prevent duplicates if results are matching...
> suppose json is : > `j := [0,1,2,3,{"4": {"test0":[1,2,3,"4"]}]` > run: > `length := gjson.Get(j, "4.:4.test0.#").Int()` > get 0; The key in your JSON is just `4`, not `:4`....
@Databingo but that's sjson documentation though and I don't see the same note on the gjson documentation. You can test what I've mentioned earlier in https://gjson.dev/ The first `.4` returns...
Sorry I'm not familiar with the `sjson` side of things, I'll leave that to @tidwall or others to answer.
@rowsimms42 did you escape the periods? See https://github.com/tidwall/gjson/blob/master/SYNTAX.md#escape-character
@rowsimms42 got it. I've never used it and I'm not sure if it's meant to be part of the public API, but there is an `escapeComp` function that seems to...