Reputation: 1585
I have a JSON object like this
"office": {
"parkingRatio": 12.0,
"hasGenerators": true,
"generators": [
{
"_id": "ff2dc672-6e15-4aa2-afb0-18f4f69596ad",
"office_id": "b62ce2c1-5fa2-4eee-9ce8-e04a2c3e6513",
"make": "Broom Broom",
"covered": true,
"output": 1234.0
}
]
}
I have a query like this:
$.office.generators[?(@._id =='ff2dc672-6e15-4aa2-afb0-18f4f69596ad')]
$.office.generators[?(@.office_id == 'b62ce2c1-5fa2-4eee-9ce8-e04a2c3e6513')]
If I run this on a few online tools like HERE:
it works fine and gives me the whole array item, but if I run it in json.net v7 it returns nothing.
So i tried the following thinking it might be string
$.office.generators[?(@.covered == true)]
And it works in online tool and json.net. So i tried the following thinking it might be the hyphens
$.office.generators[?(@.make == 'Broom Broom')]
And again it works fine in both. What is wrong with my first query?
Thanks
Upvotes: 2
Views: 1180
Reputation: 1585
Found the problem. The json _id field gets converted into a JValue of type Guid but the expression JValue gets converted into String so when "BooleanQueryExpression" does this comparison
if (v != null && v.Equals(Value))
then its not equal.
I submitted a issue on github
Upvotes: 3