PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | French EN
  • Encoding
  • Content of variant
  • Checking if a value is NULL
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Converts a JSON string to a Variant variable.
Versions 20 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
Windows Mobile This function is now available for Windows Mobile applications.
New in version 20
iPhone/iPad This function is now available for iPhone/iPad applications.
Windows Mobile This function is now available for Windows Mobile applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Windows Mobile This function is now available for Windows Mobile applications.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Versions 22 and later
Android This function is now available for Android applications.
Android Widget This function is now available in Android Widget mode.
WEBDEV - Browser code This function is now available in browser code.
New in version 22
Android This function is now available for Android applications.
Android Widget This function is now available in Android Widget mode.
WEBDEV - Browser code This function is now available in browser code.
Android This function is now available for Android applications.
Android Widget This function is now available in Android Widget mode.
WEBDEV - Browser code This function is now available in browser code.
sJZon is ANSI string = [
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
]

let jz = JSONToVariant(sJZon)
Syntax
<Result> = JSONToVariant(<JSON data>)
<Result>: Variant
Name of Variant variable containing the conversion result.
<JSON data>: ANSI character string encoded in 7-bit ASCII + JSON or UTF-8 encoding
Character string containing the data in JSON format.
Remarks

Encoding

The encoding used corresponds to the JSON standard:
  • 7-bit ASCII encoding for the first 128 characters, i.e., unaccented characters
  • JSON encoding for the other characters: "\u" followed by the character code in 4-byte hexadecimal format. Example: for the "é" character (ASCII code 233, hexadecimal code E9), the encoding corresponds to "\u00E9".

Content of variant

The content of the variant depends on the JSON used. It can correspond to:
  • the Null value
  • a simple type: integer, string, boolean, etc.
  • an array
  • a complex object (VariantMember type, corresponding to an array of members where each member is a variant).

Checking if a value is NULL

The "NULL" value is often used in JSON.
To check the "NULL" value of a variant, you can:
  • use the Value property of the variant. For example:
    v is Variant = JSONToVariant("{""m"":null}")
    IF v.m..Value = Null THEN Trace("NULL")
  • check the NULL value directly. For example:
    v is Variant = JSONToVariant("{""m"":null}")
    IF v.m = Null THEN Trace("NULL")
Component : wd260xml.dll
Minimum version required
  • Version 19
This page is also available for…
Comments
Video Json
bom dia
https://youtu.be/WkltQUt_Bak
https://windevdesenvolvimento.blogspot.com/2019/07/dicas-2204-windev-webdev-mobile-json-6.html
// Youtube Amarildo Matos
s_json_dados is string=fLoadText(EDT_ARQUIVO_JSON)
//ESSA LINHA DIFERENTE
let variavel_json=JSONToVariant(s_json_dados)
//ESSA LINHA DIFERENTE
TableDeleteAll(TABLE_JSON)
FOR nNCONTADOR=1 TO variavel_json..Count
nNOCORRENCIA is int=TableAddLine(TABLE_JSON)
TABLE_JSON[nNOCORRENCIA].COL_SHORT_DESCRIPTION=variavel_json[nNCONTADOR].short_description
TABLE_JSON[nNOCORRENCIA].COL_PRICE=variavel_json[nNCONTADOR].price
TABLE_JSON[nNOCORRENCIA].COL_STOCK_QUANTITY=variavel_json[nNCONTADOR].stock_quantity
END

amarildo
18 Jul. 2019
Video JSONToVariant
https://youtu.be/ZC3G1PrDN9g

https://windevdesenvolvimento.blogspot.com/2019/05/dicas-2107-windev-webdev-mobile-json-4.html

// BTN_LER_SJON
TableDeleteAll(TABLE_CLIENTE)
vTeste is Variant
vTeste=JSONToVariant(EDT_retorno)
FOR EACH indice OF vTeste
TableAddLine(TABLE_CLIENTE,indice.clienteid,indice.nome)
END

amarildo
13 May 2019
Ler Json e Colocar Tabela
Aula 1053 - WinDev json 2/... - Ler Jason e Adicionar Tabela - JSONVersVariant

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2017/02/aula-1053-windev-json-2-ler-jason-e.html

//Video Youtube
https://www.youtube.com/watch?v=fY9AtlEkY-8

//Nessa aula vou mostrar como ler dados Json e colocar Tabela

s_json_dados is string=[
{"status": true,"valores":
{
"USD": {"nome": "Dolar","valor": 2.333,"ultima_consulta": 1386349203,"fonte": "UOL Economia - http://economia.uol.com.br/cotacoes/"},
"EUR": {"nome": "Euro","valor": 3.195,"ultima_consulta": 1386349203,"fonte": "UOL Economia - http://economia.uol.com.br/cotacoes/"},
"BTC": {"nome": "Bitcoin","valor": 2620,"ultima_consulta": 1386352803,"fonte": "Mercado Bitcoin - http://www.mercadobitcoin.com.br/"
}
}
}
]
let jz=JSONToVariant(s_json_dados)
TableDeleteAll(TABLE_indices)
FOR EACH _m OF jz..Member
TableAddLine(TABLE_indices,_m..Name+TAB+" = "+_m..Value)
TableAddLine(TABLE_indices,"=========================")
mebros(_m)
END
INTERNAL PROCEDURE mebros(x)
FOR EACH _m2 OF x..Member
TableAddLine(TABLE_indices,_m2.nome,_m2.valor,_m2.fonte,_m2.ultima_consulta)
END
END


De matos
04 Feb. 2017