my json string is as follows:
var data = [{"first":"3","second":"1"},{"first":"5","second":"5"},{"first":"7","second":"1"}];
Now i am calling –
objx(data).collect("first")
and expecting to get an array like [3,5,7].
But i am getting javascript error : object doesn’t support this property or method.
i have tried with
objx(data).collect("first").obj() but with no avail.
i have included objx-2.3.6.js file from http://code.google.com/p/objx/ and i want to create the array with objx api to reduce no of lines of code.
i am using IE8
please suggest a way out.
“my json string” – That’s neither JSON nor a string. Anyway…
Since you’ve tagged your question with jQuery (even though you don’t mention it in your question anywhere) here is a jQuery solution to the same problem:
As far as why you’re getting the particular error you do, that would be because the
.collect()method is not part of the core objx library, at least, it is not inobjx-2.3.6.js. Presumably you need to include the Collections plugin js too (but I couldn’t find it).