ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / Managing 3-tier architecture / WLanguage functions
  • Deserialization
  • Change of behavior in version 10: generating a XML serialization for the Mobile devices
  • Speed
  • Serializing the members of classes and structures
  • Serialization name of classes
  • Limits
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Transforms the following elements into a specific format:
  • a structure (and its sub-elements).
  • a class (and its sub-elements).
  • an array (including the associative arrays).
  • a queue.
  • a stack.
  • a list.
  • an advanced type of variable (gglCalendar for example).
The available formats are XML, binary and JSON. Then, the initial format can be retrieved by Deserialize.
// Cet exemple montre l'utilisation des fonctions Sérialise/Désérialise
// avec une variable de type Tableau.
// Ces fonctions peuvent utiliser tous les types de variables WLangage.
 
MonTableau is array of strings
bufRésultat is Buffer
 
// Ajoute des éléments dans le tableau
Add(MonTableau, "WINDEV")
Add(MonTableau, "WEBDEV")
Add(MonTableau, "WINDEV MOBILE")
 
// Sérialisation du tableau dans le buffer en JSON
// => Sauvegarde du tableau et de tout son contenu dans une chaîne JSON
Serialize(MonTableau, bufRésultat, psdJSON)
 
// Désérialisation du buffer JSON
// => Reconstruction du tableau WLangage à partir de la chaîne JSON
MonTableauReconstruit is array of strings
Deserialize(MonTableauReconstruit, bufRésultat, psdJSON)
Syntax
Serialize(<Variable> , <Buffer> , <Parameters> [, <Root name>])
<Variable>: Type of variable
Variable to serialize. This variable is a structure, a class, an array, a queue, a list or a stack.
<Buffer>: Ansi character string or buffer
Variable that contains the result of serialization.
WEBDEV - Browser code Only the character string variables are available.
<Parameters>: Integer constant
Type of serialization:
psdBinaryBinary serialization.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Binary deserialization is not available.
psdBinaryFormat16Binary serialization compatible with version 16.
This format must be used if an application in version 17 or later must share data with an application in version 16 or earlier.
This format must not be used in Unicode mode.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Binary deserialization is not available.
psdJSONJSON serialization.
The encoding used corresponds to the JSON standard:
  • 7-bit ASCII encoding, i.e. the first 128 characters, unaccented characters,
  • JSON encoding for the other characters: "\u" followed by the character code in 4-byte hexadecimal format. Example: for "é" (ASCII code 233, hexadecimal code E9), the encoding corresponds to "\u00E9".
Java JSON deserialization is not available.
psdMinifiedCaution: This constant must be combined with the psdJSON constant. Otherwise, it will be ignored.
The encoding used corresponds to the JSON standard. This constant is used to generate a JSON by removing unnecessary spaces (carriage returns, spacing characters, etc.).
WEBDEV - Browser codeAndroidAndroid Widget Apple WatchJavaPHP This constant is not available.
psdFormattingSerialization in JSON or XML format with carriage return and indent.
The encoding used corresponds to the JSON or XML standard.
Caution: This constant must be combined with the psdJSON or psdXML constant.
WEBDEV - Browser codeJavaPHP The serialization in JSON format with formatting is not available.
psdXMLXML serialization with reference to sub-objects. This type of serialization allows you to use the XML format as storage and exchange modes between applications written in WLanguage.
WEBDEV - Browser code The serialization in XML format is not available.
psdXMLAggregatedXML serialization with direct aggregation of sub-objects. This type of serialization allows you to easily generate an XML file in a standard format to perform exchanges with other systems.
Remark: A deserialization in psdXMLAggregated mode is available, however the WLanguage elements (variants, arrays, derived classes, ...) will differ from the source ones.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP This serialization mode is not available.
<Root name>: Character string
Name of the root of the generated XML. This parameter is taken into account in psdXMLAggregated mode only.
If this parameter is not specified, the name of the root is "DOCUMENT".
WEBDEV - Browser code This parameter is not available.
Remarks

Deserialization

The deserialization of an array, queue, list or stack deletes the content from this element.
If there are additional members in the structure or in the class:
  • if a structure or a class is deserialized: additional members keep their values from before the deserialization.
  • if an array of structures or classes is deserialized: additional members take the default value of the member type.
If there are additional members in the serialized buffer, they are ignored during the deserialization.
To deserialize an untyped dynamic array, this array must be allocated beforehand.
To deserialize a class or a structure containing an untyped dynamic array, this array must be allocated beforehand.
The wd290xml.dll or wp290xml.dll library is necessesary to deserialize an XML document.
AndroidAndroid Widget Java In order for the serialization format to be compatible between the WINDEV applications and the WINDEV Java applications, the names of the following serialized elements must contain no special character and no accented character:
  • classes,
  • arrays of classes,
  • structures,
  • arrays of structures.
AndroidAndroid Widget XML serialization/deserialization of variants is not supported.
WEBDEV - Browser code The names of the following serialized elements must contain no special or accented characters:
  • classes,
  • arrays of classes,
  • structures,
  • arrays of structures.

Change of behavior in version 10: generating a XML serialization for the Mobile devices

Until version 100050, the psdXML constant did not generate a valid XML file. The generated format caused problems on Mobile devices. This problem was fixed.
An XML file created with a version later than version 100050 cannot be read by a program compiled with an earlier version. To keep the operating mode of version 100050, all you have to do is use the psdXML_OldFormat constant.

Speed

The binary serialization is faster than the XML serialization.

Serializing the members of classes and structures

By default, all the members of a class or structure are serialized.
You have the ability to precisely manage the serialization of each member:
  • by specifying the member that will be serialized during the call to Serialize.
    This operation can be performed on all types of serialization (XML, JSON, binary).
    WEBDEV - Browser codePHP Feature not available.
  • by changing the name of the member during the serialization with Serialize.
    This operation can be performed during a binary serialization only.
    WEBDEV - Browser codePHP Feature not available.
This management of serialization is performed by using the following syntax:
  • Serialization (or not) of a member :
    <Nom du membre> est un <Type du membre> [, Sérialise = <Vrai / Faux>] [, xmlAttribut]
  • Serialization and change of member name:
    <Nom du membre> est un <Type du membre> [, Sérialise = <Nouveau nom>] [, xmlAttribut]
The "xmlAttribute" extension attribute is used to specify that the member is created as attribute (instead of tag). This attribute is taken into account during a psdXMLAggregated serialization only.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP The "xmlAttribute" extension attribute is not available.
Example for a class:
Cl is Class
// Membre sérialisé
MembreSérialisé is int
// Membre non sérialisé
MembreNonSérialisé is string, serialize = false  
// Membre renommé lors de la sérialisation
MembreRenommé is int, serialize = "NouveauNomMembre"
END
Remark: To avoid serializing an array member, use the following syntax:
t1 est un tableau <Sérialise = Faux> d'entier
t2 est un tableau <Sérialise = "<nom de sérialisation>"> d'entier

Serialization name of classes

The "Serialize" extension attribute is available for the classes in order to specify the serialization name.
The following syntax is used:
<Nom de la classe> est une Classe [, Sérialise = <Nouveau nom>]
WEBDEV - Browser codePHP Feature not available.
Example:
CTest is Class, serialize = "Test"
m_sNom is string, serialize = "Nom"
m_sPrenom is string, serialize = "Prenom"
m_sSuitePrenom is string, serialize = "SuitePrenom"
END
 
sXML is Buffer
monTest is CTest
monTest.m_sNom = "Mon Nom"
monTest.m_sPrenom = "Mon Prénom"
monTest.m_sSuitePrenom = "Mon Prénom Mon Prénom"
Serialize(monTest, sXML, psdXMLAggregated)
 
 
// Contenu de sXML où l'on retrouve bien les noms de la sérialisation:
// <?xml version="1.0" encoding="UTF-8"?>
// <Test>
//  <Nom>Mon Nom</Nom>
//  <Prenom>Mon Prénom</Prenom>
//  <SuitePrenom>Mon Prénom Mon Prénom</SuitePrenom>
// </Test>

Limits

  • The fixed arrays and the associative arrays of local structures cannot be serialized.
  • The global members of classes are not serialized.
  • The XML serialization/deserialization of an array of structures with a string member containing "\0" or Charact(0) returns the following error: "Wrong serialization format". In this case, a binary serialization/deserialization must be performed.
  • You cannot serialize/deserialize an array of classes or structures if this class or structure contains a dynamic array without type. A dynamic array with defined type must be used in this class or in this structure.
  • To serialize/deserialize a class, you must have a constructor with 0 parameter.
  • stacks, queues, lists:
    • The JSON serialization of stacks, queues and lists is not available.
    • AndroidAndroid Widget Java You cannot serialize/deserialize Queue, Stack or List variables.
  • Only JSON serialization is available for Record variables. No deserialization is possible.
Business / UI classification: Neutral code
Component: wd290vm.dll
Minimum version required
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/30/2023

Send a report | Local help