0

I am trying to retrieve values from a simple JSON file.

I can get the first value: total but when it comes to model and processorSpeed i'm stuck. Can someone help me please.

<%
Response.LCID = 2057 
%>
<!--#include file="jsonObject.class.asp" -->
<%

Dim jsonString
jsonString = "{ ""total"": 1 , ""results"":[{""model"":""MacBook Pro"",""processorSpeed"":""2.6 GHz""}]}"

Dim jsonObj, outputObj
set jsonObj = new JSONobject
set outputObj = jsonObj.parse(jsonString)

response.write("<li> total :" & outputObj("total") & "</li>")
response.write("<li> model :" & outputObj("results.model") & "</li>")
response.write("<li> processorSpeed :" & outputObj("results.processorSpeed") & "</li>") 

%>

Output I get:

total :1
model :
processorSpeed :

Thanks

Rick Kap
  • 159
  • 1
  • 9

1 Answers1

0

Results has array objects, outputObj("results.model") not correct.

edit = Parsing string array from JSON object look up

Melih Sevim
  • 930
  • 6
  • 9
  • Thank you for point this out to me and I was just about to point this out after googling it. The problem I have is I don't know what the correct coding is to extract the values model and processorSpeed. I have looked at the link you supplied but they aren't in Classic ASP – Rick Kap Dec 04 '18 at 14:53