ASP JSON: Object not a collection -
how should retrieve pitcherid json? using class http://aspjson.com.
json
[ { "pitcherid": "456068" }, { "pitcherid": "431148" } ]
code
ojson.loadjson("...") each thing in ojson.data("pitcherid") set = ojson.data("pitcherid").item(thing) response.write this.item("pitcherid") next
error
microsoft vbscript runtime error '800a01c3' object not collection
in experience it's far easier use jscript server side scripting language use aspjson class. render json object follows
<%@language="javascript"%> <!doctype html> <html> <body> <% var ojson =[ { "pitcherid": "456068" }, { "pitcherid": "431148" } ] (i in ojson) { response.write((ojson[i].pitcherid) + "<br />"); } %> </body> </html>
i realise may cause problems if json processing part of page , rest of uses vbscript, can execute server side js in otherwise vbs page using <script runat="server">
eg
<%@language="vbscript"%> <!doctype html> <html> <head> <script language="javascript" runat="server"> var ojson =[ { "pitcherid": "456068" }, { "pitcherid": "431148" } ] var strout = "" (i in ojson) { strout = strout + ((ojson[i].pitcherid) + "<br />"); } </script> </head> <body> <% response.write strout %> </body> </html>
Comments
Post a Comment