Page 1 of 1

Problem with Json

Posted: Fri Feb 06, 2015 7:10 pm
by Marco Turco
Hi all.
I need to create this json to send it via http post
My problem is that this row return me an array access error
ahash["posta_options"]["sender"]["indirizzo"] = "Via Zama 4"

Any ideas ? This is the full code:


aHash := hash()
ahash["sender"] = "LOGIC SRL"
ahash["posta_options"] := hash()
ahash["posta_options"] := hash()["sender"] := hash()
ahash["posta_options"]["sender"]["indirizzo"] = "Via Zama 4"
ahash["posta_options"]["sender"]["cap"] = "20110"
ahash["posta_options"]["sender"]["citta"] = "Milano"
ahash["posta_options"]["sender"]["provincia"] = "MI"
ahash["posta_options"]["sender"]["nazione"] = "Italia"

cJson := hb_jsonEncode(ahash,.f.)

Re: Problem with Json

Posted: Fri Feb 06, 2015 10:17 pm
by Enrico Maria Giordano
Marco,

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL aHash := hash()

    LOCAL cJson

    ahash["sender"] = "LOGIC SRL"
    ahash["posta_options"] := hash()
    ahash["posta_options"]["sender"] := hash()
    ahash["posta_options"]["sender"]["indirizzo"] = "Via Zama 4"
    ahash["posta_options"]["sender"]["cap"] = "20110"
    ahash["posta_options"]["sender"]["citta"] = "Milano"
    ahash["posta_options"]["sender"]["provincia"] = "MI"
    ahash["posta_options"]["sender"]["nazione"] = "Italia"

    cJson := hb_jsonEncode(ahash,.f.)

    ? cJson

    RETURN NIL
EMG

Re: Problem with Json

Posted: Sun Feb 08, 2015 9:23 pm
by Marco Turco
It is fine. Thank you very much Enrico.

Re: Problem with Json

Posted: Thu May 06, 2021 11:56 am
by Romeo
Ciao

Mai avuto a che fare con tematica INVIO DATI TESSERA SANITARIA ?