Home | Sign in | English UK
New WINDEV, WEBDEV, WINDEV Mobile 24 feature!
  • Importing files in JSON format
  • Assignment and reading
  • Properties specific to the description of JSON variables
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Stored procedures
The JSON type makes it possible to simplify actions on data in JSON format.

Declaring and assigning a JSON type Hide the details

<Variable name> is JSON = <Value>


 <Variable name> is JSON
 <Variable name> = <Value>
<Variable name>:
Name of variable to declare.
Value that will be assigned to the variable. A JSON variable can be assigned with:
  • NULL,
  • a Boolean (True or False),
  • a numeric.
  • a date (automatically converted into string in RFC format),
  • an Ansi or Unicode string that contains data,
  • an Ansi string that contains data in JSON format.

Importing files in JSON format

JSON variables can be declared by specifying an example document (a text file). The structure of this document will be read by WINDEV, WEBDEV and WINDEV Mobile. Therefore, the automatic completion will be available for the names of nodes in the code editor.
To declare a JSON variable with an example document:
  1. Add the text document to the project using one of the following methods:
    • on the "Project" pane, in the "Project" group, expand " List of elements" and click "List of project elements". The list of project elements is displayed. Click on "Add" and select the text document.
    • Drag the file and drop it in the "External descriptions" folder of the "Project explorer" pane.
    • in the "Project explorer" pane, select the "External descriptions" folder, then "Import an XML or JSON into this project" from the popup menu.
  2. The JSON document appears in the "External Descriptions" folder of the Project explorer. You have the ability to see its structure.
  3. Declare the variable as follows:
    <Variable name> is JSON, description =  <Document name>

    <Variable name> is JSON <description =  "Document name">

    <Document name> can correspond to the name of the example document (with or without extension).
    Note: This declaration can be automatically obtained by dropping the name of the text document from the project explorer.
  4. You now have the ability to access the variable nodes by their names. These names are automatically proposed by the mechanism for automatic completion of the code editor.
Note: It is also possible to obtain compilation assistance and verification on a sub-part of the JSON by using the following syntax:
v2 is JSON, description="JSONFile.Member.SubMember"

v2 is JSON, <description="JSONFile.Member.SubMember">

Assignment and reading

Assigning a JSON variable
The notation "j = ..." tries to analyze the value as a JSON string. This notation is "almost" equivalent to "j..JSONFormat = ..." except if the JSON string is invalid: it is then copied directly without interpretation, as the value of the JSON element
The notation "j.member = ..." assigns the value of the member. This notation is equivalent to "j.member..Value =... ".
Reading a JSON variable
The notation "... = j" returns the JSON string corresponding to the content of the variable. This notation is equivalent to "... =j..JSONFormat ".
The notation "... = j.member" returns the value of the member. This notation is equivalent to "... =j.member..Value".

Properties specific to the description of JSON variables

The following properties can be used to handle a JSON variable:
Property nameType usedEffect
  • True if the element exists,
  • False otherwise.
This property is available in read-only.
JSONFormatCharacter stringJSON string corresponding to the value of the element. If this string is not in JSON format, a warning is displayed.
NameCharacter stringMember name. Corresponds to empty string ("") if there is no member.
CountIntegerNumber of elements:
  • 1 for simple elements and objects,
  • Number of elements for arrays.
This property is available in read-only.
TypeIntegerType of element. This property is available in read-only.
ValueAll types
  • Value of a simple element,
  • NULL for a complex element.

Note: These properties can be handled by using one of the following syntaxes:
  • <Variable name>..<Property name>
  • <Variable name>.<Property name>
Minimum version required
  • Version 24
This page is also available for…
Video Json

json_Variavel is a JSON=[
"Codigo": 24000,
"Nome": "WINDEV 24"
11 Jul. 2019