.Where() problems when used with numbers.

Apr 5, 2013 at 1:26 PM
Consider the same json array..

var jsonArray = [
{ "user": { "id": 100, "screen_name": "d_linq" }, "text": "to objects" },
{ "user": { "id": 130, "screen_name": "c_bill" }, "text": "g" },
{ "user": { "id": 155, "screen_name": "b_mskk" }, "text": "kabushiki kaisha" },
{ "user": { "id": 301, "screen_name": "a_xbox" }, "text": "halo reach" }
]

var queryResult = Enumerable.From(jsonArray).Where("$.user.text == 'g'").ToArray();

if i use above statement on 'text' field, it works perfectly fine.


var queryResult = Enumerable.From(jsonArray).Where("$.user.id == 100").ToArray();

but when i try to use above statement on 'id' field, it does not filter the result accordingly, instead it returns complete json array.


I also tried converting integers from json array to strings as shown below bu it did not help either.

var jsonArray = [
            { "user": { "id": "100", "screen_name": "d_linq" }, "text": "to objects" },
            { "user": { "id": "100", "screen_name": "c_bill" }, "text": "g" },
            { "user": { "id": "155", "screen_name": "b_mskk" }, "text": "kabushiki kaisha" },
            { "user": { "id": "301", "screen_name": "a_xbox" }, "text": "halo reach" }
        ]
I tried using '=' , '==' and putting single quotes, etc etc in lambda equations but no luck.

It works perfectly fine for strings with alphabets and not for numbers.

Please help me.
May 8, 2013 at 3:57 AM
You should use this statement

var queryText = Enumerable.From(jsonArray).Where("$.text == 'g'").ToArray();
var queryId = Enumerable.From(jsonArray).Where("$.user.id == '135'").ToArray();