-1

Please help me to read json response filed value in classic asp.

For example:

I am getting below response in classic asp. I require deliveryNo and content value. Please help on this:

{"labels":[{"shipmentID":"a2f3vh3","deliveryNo":"1234","content":"test","invoice":null,"responseStatus":{"code":200,"message":"SUCCESS","messageDetails":"All shipments processed and label/invoice generated successfully","logMsg":[]}}],"responseStatus":{"code":200,"message":"SUCCESS","messageDetails":"All shipments processed successfully","logMsg":[]}} 
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Rajanikumar
  • 3
  • 1
  • 2
  • 4
  • 1
    Possible duplicate of [Any good libraries for parsing JSON in Classic ASP?](http://stackoverflow.com/questions/1019223/any-good-libraries-for-parsing-json-in-classic-asp) – user692942 Dec 03 '16 at 22:56

2 Answers2

1

You could use ASPJSON

aspjson is JSON serializer for VBScript based ASP server technology.

Alex Hedley
  • 776
  • 10
  • 24
  • There is already a perfectly good question with answers that lists all the JSON parsing options for Classic ASP, we don't need another one and sure don't need to encourage more of them by writing duplicate answers. – user692942 Dec 03 '16 at 23:15
  • @VanquishedWombat really, [what's this then](http://stackoverflow.com/questions/40948026/how-to-read-json-respone-field-value-in-classic-asp/40948242?noredirect=1#comment69116577_40948026)? – user692942 Dec 07 '16 at 10:17
  • @VanquishedWombat you're correct it points to the comment that contains linked question that I'm referring to. The fact it says *"Possible duplicate"* is that lost on you or something? – user692942 Dec 07 '16 at 10:36
  • @VanquishedWombat it's got nothing to do with authoritative it's just disheartening to see the same questions being asked over and over. In terms of question it's pretty poor but instead of marking as a duplicate a moving on people post duplicate content that already exists elsewhere. – user692942 Dec 07 '16 at 11:04
  • @VanquishedWombat So I did two things 1. I flagged the question as [a duplicate](http://stackoverflow.com/help/duplicates) *(how is that clutter??)* 2. I replied to this answer as they should be adding their answer to the original question not this one, but then they'll find it's already there which makes this answer pointless. If people just read [ask] and look through the help topics or even asked in meta how to ask and answer this wouldn't happen. – user692942 Dec 07 '16 at 11:04
1

At the risk of annoying people by answering something that has been answered already lots of times, I use a solution which used to be available via http://www.aspjson.com/, but the site seems to be down now.

I still use the code though - it's here http://pastebin.com/qvn2UxXV

This is a very simple example of how to use it with your data, to get at deliveryNo and Content:

<!--#INCLUDE file="aspJSON.asp" -->
<%
Set oJSON = New aspJSON

jsonstring = "{""labels"":[{""shipmentID"":""a2f3vh3"",""deliveryNo"":""1234"",""content"":""test"",""invoice"":null,""responseStatus"":{""code"":200,""message"":""SUCCESS"",""messageDetails"":""All shipments processed and label/invoice generated successfully"",""logMsg"":[]}}],""responseStatus"":{""code"":200,""message"":""SUCCESS"",""messageDetails"":""All shipments processed successfully"",""logMsg"":[]}}"

Set oJSON = New aspJSON
oJSON.loadJSON(jsonstring)

For Each result In oJSON.data("labels")

    Set this = oJSON.data("labels").item(data)

    var_deliveryNo = this.item("deliveryNo")
    var_content = this.item("content")

    response.write "deliveryNo: " & var_deliveryNo & "<br />"
    response.write "content: " & var_content & "<br />"

Next
%>
4532066
  • 2,042
  • 5
  • 21
  • 48