0

I want to know how I can read JSON when it comes directly from another server, like a form. I have to request and process JSON.

dim datos: set datos = json.parse(BodyJson)
    dim key : for each key in datos.keys() 
        Status = datos.get(key).category 
        FechaHoraEnvio = datos.get(key).date 
        DireccionEmail =  datos.get(key).recipient
        InfoExtra = datos.get(key).tags
        ID= 123
        sSQL = "INSERT INTO EmailsStatus (Id, Status, FechaHoraEnvio, DireccionEmail, InfoExtra) VALUES ('"& ID &"', '"& Status &"', '"& FechaHoraEnvio &"', '"& DireccionEmail &"', '"& InfoExtra &"')"
        Response.write sSql
        objAccessDB.excecuteQuery(sSQL)
    next
Teun Zengerink
  • 4,277
  • 5
  • 30
  • 32
  • Check this previous SO post http://stackoverflow.com/questions/1019223/any-good-libraries-for-parsing-json-in-classic-asp – AardVark71 Oct 04 '12 at 16:09
  • i prefer json2.asp in the AXE framework – Rafael Oct 04 '12 at 18:50
  • Cool, I had a look at the json2.asp code on github and it already implements the SO post suggestion to use the Douglas Crockford json2.js library – AardVark71 Oct 05 '12 at 09:46
  • Could you specify a bit more what your problem is? Are you having trouble getting the "BodyJson" or trouble getting Status, FechaHoraEnvio, DireccionEmail , InfoExtra ? – AardVark71 Oct 05 '12 at 09:52

1 Answers1

0

Try using

dim datos: set datos = json.parse(BodyJson)
dim key : for each key in datos.keys()
    if (key = "category") then Status = datos.get(key)
    if (key="date") then FechaHoraEnvio = datos.get(key)
    if (key = "recipient") then DireccionEmail =  datos.get(key)
    if (key = "tags") then InfoExtra = datos.get(key)
    ID= 123
    sSQL = "INSERT INTO EmailsStatus (Id, Status, FechaHoraEnvio, DireccionEmail, InfoExtra) VALUES ('"& ID &"', '"& Status &"', '"& FechaHoraEnvio &"', '"& DireccionEmail &"', '"& InfoExtra &"')"
    Response.write sSql
    objAccessDB.excecuteQuery(sSQL)
next
AardVark71
  • 3,928
  • 2
  • 30
  • 50