Webservice JSON + ASP
Fala pessoal,
estou com um probleminha com uma integração, onde preciso ler um resposta JSON em ASP Clássico.
a resposta é
{"id":1,"name":"PAC","price":"45.65","custom_price":"45.65","discount":"7.41","currency":"R$","delivery_time":8,"delivery_range":{"min":8,"max":8},"custom_delivery_time":8,"custom_delivery_range":{"min":8,"max":8},"packages":{"price":"45.65","discount":"7.41","format":"box","dimensions":{"height":20,"width":20,"length":20},"weight":"1.00","insurance_value":"1000.00","products":{"id":"teste1","quantity":1}},"additional_services":{"receipt":true,"own_hand":false,"collect":false},"company":{"id":1,"name":"Correios","picture":"https:\/\/sandbox.melhorenvio.com.br\/images\/shipping-companies\/correios.png"}},{"id":2,"name":"EXPRESSO","price":"68.51","custom_price":"68.51","discount":"11.95","currency":"R$","delivery_time":5,"delivery_range":{"min":5,"max":5},"custom_delivery_time":5,"custom_delivery_range":{"min":5,"max":5},"packages":{"price":"68.51","discount":"11.95","format":"box","dimensions":{"height":20,"width":20,"length":20},"weight":"1.00","insurance_value":"1000.00","products":{"id":"teste1","quantity":1}},"additional_services":{"receipt":true,"own_hand":false,"collect":false},"company":{"id":1,"name":"Correios","picture":"https:\/\/sandbox.melhorenvio.com.br\/images\/shipping-companies\/correios.png"}},{"id":3,"name":".Package","price":"33.51","custom_price":"33.51","discount":"15.58","currency":"R$","delivery_time":6,"delivery_range":{"min":5,"max":6},"custom_delivery_time":6,"custom_delivery_range":{"min":5,"max":6},"packages":{"format":"box","dimensions":{"height":20,"width":20,"length":20},"weight":"1.00","insurance_value":"1000.00","products":{"id":"teste1","quantity":1}},"additional_services":{"receipt":true,"own_hand":false,"collect":false},"company":{"id":2,"name":"JadLog","picture":"https:\/\/sandbox.melhorenvio.com.br\/images\/shipping-companies\/jadlog.png"}},{"id":4,"name":".Com","price":"32.63","custom_price":"32.63","discount":"26.48","currency":"R$","delivery_time":5,"delivery_range":{"min":4,"max":5},"custom_delivery_time":5,"custom_delivery_range":{"min":4,"max":5},"packages":{"format":"box","dimensions":{"height":20,"width":20,"length":20},"weight":"1.00","insurance_value":"1000.00","products":{"id":"teste1","quantity":1}},"additional_services":{"receipt":true,"own_hand":false,"collect":false},"company":{"id":2,"name":"JadLog","picture":"https:\/\/sandbox.melhorenvio.com.br\/images\/shipping-companies\/jadlog.png"}}
Tenho a seguinte página para receber essa resposta
<!--#include file="includes/json2.asp"-->
<%
Dim objXML, Result
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
On Error Resume Next
For i = 1 To 3
objXML.Open "POST" , url, False , "", ""
objXML.setRequestHeader "content-type", "application/json"
objXML.setRequestHeader "accept", "application/json"
objXML.setRequestHeader "authorization", "Bearer " & Bearer
objXML.Send variavel_json
If Err.Number = 0 Then
Result = objXML.ResponseText
end if
Exit For
Next
Set objXML = Nothing
Result = replace(replace(Result,"[",""),"]","")
a=Split(Result,".png""}},")
For Each x In a
set x = JSON.parse(Result)
Response.write(x.name & vbNewline)
Response.write(x.price & vbNewline)
Response.write(x.delivery_time & vbNewline)
Response.write(x.company.name & vbNewline)
Next
%>
O que ocorre, é que imprimi somente a última linha
.Com 32.63 5 JadLog .Com 32.63 5 JadLog .Com 32.63 5 JadLog .Com 32.63 5 JadLog
Alguém poderia me dizer onde estou errando?
Agradeço a atenção de todos!
Abraços
Discussão (0)
Carregando comentários...