0
I am new to advpl, and need to create a Hashmap object. I will leave part of my code to see if you can help me.
If !empty(cJsonCOT)
// Cria o objeto para fazer o parser do Json
oJsonObj := tJsonParser():New()
// Faz o Parser da mensagem JSon e extrai para Array (aJsonfields) e cria tambem um HashMap para os dados da mensagem (oJHM)
lRet := oJsonObj:Json_Hash(cStrJson, nLenStrJson, @aJsonfields, @nRetParser, @oJHashMap)
If ( !lRet )
MsgStop(cStrJson,"Falha ao solicitar dados")
else
// Obtem o valor dos campos usando o Hashmap gerado
HMGet(oJHashMap, "erro", @lCotERRO)
If lCotERRO
MsgStop("##### [JSON][ERR] " + "Parser com erro" + " MSG len: " + AllTrim(Str(nLenStrJson)) + " bytes lidos: " + AllTrim(Str(nRetParser)))
Else
// Obtem o valor dos campos usando a chave
HMGet(oJHashMap, "valorCompra", cCompra)
ENDIF
ENDIF
// Limpa os objetos utilizados
FreeObj(oJsonObj)
FreeObj(oJHashMap)
ENDIF
The only thing I can’t do is create the object -> @oJHashMap
All variables are declared according to their type.
All these parameters are fine (Strjson, nLenStrJson, @aJsonfields, @nRetParser). They have their correct data.
lRet := oJsonObj:Json_hash(cStrJson, nLenStrJson, @aJsonfields, @nRetParser, @oJHashMap) -> But in this line, according to the theory (which I obviously don’t understand), this object must be created. But it doesn’t happen, it just has nothing.
This code is just an example. From this object, I need several data. That in the example I am looking for only one. Because my problem is that the object is not being created for some reason.
Daregny, your goal is just to get the value of JSON?
– Daniel Mendes