#include "protheus.ch"
user function DNExemplo()
local oJson
local ret
oJson := JsonObject():new()
ret := oJson:fromJson('{"character":"Joaquim", "json":{"Joao":22, "Joana":33}, "array":[4,12,5], "numeric":23, "logic":false, "nil":null}')
if ValType(ret) == "U"
Conout("JsonObject populado com sucesso")
else
Conout("Falha ao popular JsonObject. Erro: " + ret)
endif
u_PrintJson(oJson)
/*
Será impresso:
Label - character
character = Joaquim
Label - numeric
numeric = 23
Label - logic
Label - array
Vetor[
Indice 1
4
Indice 2
12
Indice 3
5
]Vetor
Label - nil
Label - json
*/
oJson:DelName("json")
u_PrintJson(oJson)
/*
Label - character
character = Joaquim
Label - numeric
numeric = 23
Label - logic
Label - array
Vetor[
Indice 1
4
Indice 2
12
Indice 3
5
]Vetor
Label - nil
*/
return
|