I need to select two fields out of three fields from Json data using Linq.js
Required output should be
[{ "A": -27, C: "country 1" } , { "A": 28 , C: "country 2"} ]
using "linq.js" from following path: [ https://raw.github.com/gist/1175460/fb7404d46cab20e31601740ab8b35d99a584f941/linq.js ]
Sample data
var Data = [{ "A": -27, "B": -39, C: "country 1" }, { "A": 28, "B": 0 , C: "country 2"}]
var filter = " x => x['A'], x['C'] ";
var findItem = Enumerable.From(Data)
.Select(filter)
.ToArray();
console.log(findItem);
code at JsFiddle : http://jsfiddle.net/gLXNw/9/
Your "lambda" function must return a valid java object.
Your query should be more like this:
var query = Enumerable.From(data)
.Select("x => { A: x['A'], X: x['C'] }") // object initializer
.ToArray();