PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Encoding
  • Content of variant
  • Checking NULL on a value
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 string in JSON format into a Variant variable.
Versions 20 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
Windows Mobile This function is now available for the Windows Mobile applications.
New in version 20
iPhone/iPad This function is now available for the iPhone/iPad applications.
Windows Mobile This function is now available for the Windows Mobile applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Windows Mobile This function is now available for the Windows Mobile applications.
Versions 21 and later
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch 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 the 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 the 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 the 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:
  • using an encoding in 7-bit ASCII, which means the first 128 characters, the non-accented characters,
  • using a JSON encoding of other characters: "\u" followed by the character code in hexadecimal on 4. Example: for "é" (ASCII code 233, hexadecimal code E9), the encoding corresponds to "\u00E9".

Content of variant

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

Checking NULL on a value

The "NULL" value is often used in JSON.
To check the "NULL" value of a variant, you can:
  • use the ..Value property of variant. For example:
    v is Variant = JSONToVariant("{""m"":null}")
    IF v.m..Value = Null THEN Trace("NULL")
  • Versions 23 and later
    check the NULL value directly (available from version 230042). For example:check the NULL value directly. For example:
    v is Variant = JSONToVariant("{""m"":null}")
    IF v.m = Null THEN Trace("NULL")
    New in version 23
    check the NULL value directly (available from version 230042). For example:check the NULL value directly. For example:
    v is Variant = JSONToVariant("{""m"":null}")
    IF v.m = Null THEN Trace("NULL")
    check the NULL value directly (available from version 230042). For example:check the NULL value directly. For example:
    v is Variant = JSONToVariant("{""m"":null}")
    IF v.m = Null THEN Trace("NULL")
Components
WINDEVWEBDEV - Server codeReports and Queries wd230vm.dll
Windows Mobile wp230vm.dll
WEBDEV - Browser code WDJS.DLL
Linux wd230vm.so
Android wd230android.jar
Minimum required version
  • Version 19
This page is also available for…
Comments
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
Feb. 04 2017