Histórico da Página
| Composition Setup |
|---|
import.css=/download/attachments/6062824/tecnologia.css
|
...
Permite exportar o objeto JSON para uma string em formato JSON.
Sintaxe
| Bloco de código |
|---|
JsonObject:toJSON( )
|
Retorno
Nome | Tipo | Descrição |
|---|---|---|
cJSON | caractere | Retorna o objeto em uma string em formato JSON |
Exemplo
| Bloco de código | ||||||||
|---|---|---|---|---|---|---|---|---|
| ||||||||
user function toJsonExemplo()
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_PrintJsonconout(oJson:toJson()) /* 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 */ return user function PrintJson(jsonObj) local i, j local names local lenJson local item lenJson := len(jsonObj) if lenJson > 0 for i := 1 to lenJson u_PrintJson(jsonObj[i]) next else names := jsonObj:GetNames() for i := 1 to len(names) conout("Label - " + names[i]) item := jsonObj[names[i]] if ValType(item) == "C" .or. ValType(item) == "N" conout( names[i] + " = " + cvaltochar(jsonObj[names[i]])) else if ValType(item) == "A" conout("Vetor[") for j := 1 to len(item) conout("Indice " + cValtochar(j)) if ValType(item[j]) == "J" u_PrintJson(item[j]) else conout(cvaltochar(item[j])) endif next j conout("]Vetor") endif endif next i endif return {"character":"Joaquim","numeric":23,"logic":false,"array":[4,12,5],"nil":null,"json":{"Joana":33,"Joao":22}}
*/
return
|
| Composition Setup |
|---|
import.css=/download/attachments/6062824/tecnologia.css |
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas