I’m new to linq.js. I’d like to do a GroupBy(), which is then converted to JSON. However, I’m getting back a string array.
var data = [ { "Gender":"M" }, { "Gender":"M" }, { "Gender":"F" } ];
var grouped_dt = Enumerable.From(data).GroupBy("$.Gender", "", 'key,e=>key+":"+e.Count()', "").ToJSON();
My result then looks something like this: [ "M:2", "F:1" ], which hardly looks like JSON (furthermore it is a string; I can alert() it immediately).
Does anybody have any idea where in my syntax am I screwing up? A confession: the data is just a simplified version of the data that I am getting from my server via AJAX, but it is completely in JSON format.
Turns out that I’d need to specify a key for each value (following the actual JSON format).
Having done this, I’d also need to
to convert it into a JSON object for use.