PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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.
  • Versions 15 and later
    an advanced type of variable (gglCalendar for example).
    New in version 15
    an advanced type of variable (gglCalendar for example).
    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.
Versions 15 and later
Java This function is now available for the Java applications.
PHP This function is now available for the PHP sites.
Android This function is now available for the Android applications.
New in version 15
Java This function is now available for the Java applications.
PHP This function is now available for the PHP sites.
Android This function is now available for the Android applications.
Java This function is now available for the Java applications.
PHP This function is now available for the PHP sites.
Android This function is now available for the Android applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
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
WEBDEV - Browser code This function is now available in browser code.
New in version 22
WEBDEV - Browser code This function is now available in browser code.
WEBDEV - Browser code This function is now available in browser code.
// This example explains how to use the Serialize/Deserialize functions
// with an Array variable.
// These functions can use all types of WLanguage variables.


MyArray is array of strings
bufResult is Buffer

// Adds elements into the array
Add(MyArray, "WINDEV")
Add(MyArray, "WEBDEV")
Add(MyArray, "WINDEV MOBILE")

// Serialize the array in the buffer in JSON
// => Save the array and its entire content in a JSON string
Serialize(MyArray, bufResult, psdJSON)

// Deserialize the JSON buffer
// => Rebuild the WLanguage array from the JSON string
MyRebuiltArray is array of strings
Deserialize(MyRebuiltArray, bufResult, 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.
Versions 22 and later
WEBDEV - Browser code Only the character string variables are available.
New in version 22
WEBDEV - Browser code Only the character string variables are available.
WEBDEV - Browser code Only the character string variables are available.
<Parameters>: Integer constant
Type of serialization:
psdBinaryBinary serialization.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP The binary deserialization is not available.
Versions 17 and later
psdBinaryFormat16
New in version 17
psdBinaryFormat16
psdBinaryFormat16
Binary serialization in 16 compatible format.
This format must be used if an application in version 17 must provide data to an application in version 16 or earlier.
This format must not be used in Unicode mode.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP The binary deserialization is not available.
Versions 19 and later
psdJSON
New in version 19
psdJSON
psdJSON
Serialization in JSON format.
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".
AndroidAndroid Widget Java The deserialization in JSON format is not available.
JavaPHP The deserialization in JSON format is not available.
Versions 20 and later
AndroidAndroid Widget The serialization in JSON format is now available.
New in version 20
AndroidAndroid Widget The serialization in JSON format is now available.
AndroidAndroid Widget The serialization in JSON format is now available.
Versions 22 and later
psdFormatting
New in version 22
psdFormatting
psdFormatting
Serialization 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.
Windows Mobile The XML serialization can only be performed in a Buffer variable.
WEBDEV - Browser code The serialization in XML format is not available.
Versions 20 and later
psdXMLAggregated
New in version 20
psdXMLAggregated
psdXMLAggregated
XML serialization with direct aggregation of sub-objects. The type of serialization allows you to easily generate an XML file in standard format, used to perform exchanges with other systems.
Note: A deserialization in psdXMLAggregated mode is available, however the WLanguage elements (variants, arrays, derived classes, ...) will differ from the source ones.
Windows Mobile The XML serialization can only be performed in a Buffer variable.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP This serialization mode is not available.
<Root Name>: Character string (with quotes)
Versions 20 and later
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.
New in version 20
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.
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 additional members are found in the structure or in the class:
  • if a structure or a class is deserialized: the additional members keep the value they had before the deserialization.
  • if an array of structure or class is deserialized: the additional members take the default value of the member type.
If additional members are found 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 XML deserialization requires the wdxxxxml.dll or wpxxxxml.dll library.
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,
  • array of structures.
WEBDEV - Browser code The names of the following serialized elements must contain no special character and no accented character:
  • classes,
  • arrays of classes,
  • structures,
  • array of structures.

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

Up to version 100050, the use of the psdXML constant did not generate a valid XML file. The generated format caused a problem on the 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.
Versions 19 and later

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 member name during the serialization by Serialize.
    This operation can be performed during a binary serialization only.
    WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Feature not available.
    Versions 23 and later
    AndroidAndroid Widget Java This feature is now available.
    New in version 23
    AndroidAndroid Widget Java This feature is now available.
    AndroidAndroid Widget Java This feature is now available.
    WEBDEV - Browser codePHP Feature not available.
This management of serialization is performed by using the following syntax:
  • Serialization (or not) of a member :
    <Member Name> is <Member Type> [, Serialize = <True/False>] [, xmlAttribute]
  • Serialization and change of member name:
    <Member Name> is <Member Type> [, Serialize = <New Name>] [, xmlAttribute]
Versions 20 and later
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.
New in version 20
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.
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
// Serialized member
SerializedMember is int
// Non-serialized member
NonSerializedMember is string, Serialize = False  
// Member renamed during the serialization
RenamedMember is int, Serialize = "NewMemberName"
END
Note: To avoid serializing an array member, use the following syntax:
t is array <Serialize = False> of int
t2 is array <Serialize = "<serialization name>"> of int
New in version 19

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 member name during the serialization by Serialize.
    This operation can be performed during a binary serialization only.
    WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Feature not available.
    Versions 23 and later
    AndroidAndroid Widget Java This feature is now available.
    New in version 23
    AndroidAndroid Widget Java This feature is now available.
    AndroidAndroid Widget Java This feature is now available.
    WEBDEV - Browser codePHP Feature not available.
This management of serialization is performed by using the following syntax:
  • Serialization (or not) of a member :
    <Member Name> is <Member Type> [, Serialize = <True/False>] [, xmlAttribute]
  • Serialization and change of member name:
    <Member Name> is <Member Type> [, Serialize = <New Name>] [, xmlAttribute]
Versions 20 and later
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.
New in version 20
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.
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
// Serialized member
SerializedMember is int
// Non-serialized member
NonSerializedMember is string, Serialize = False  
// Member renamed during the serialization
RenamedMember is int, Serialize = "NewMemberName"
END
Note: To avoid serializing an array member, use the following syntax:
t is array <Serialize = False> of int
t2 is array <Serialize = "<serialization name>"> of int

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 member name during the serialization by Serialize.
    This operation can be performed during a binary serialization only.
    WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Feature not available.
    Versions 23 and later
    AndroidAndroid Widget Java This feature is now available.
    New in version 23
    AndroidAndroid Widget Java This feature is now available.
    AndroidAndroid Widget Java This feature is now available.
    WEBDEV - Browser codePHP Feature not available.
This management of serialization is performed by using the following syntax:
  • Serialization (or not) of a member :
    <Member Name> is <Member Type> [, Serialize = <True/False>] [, xmlAttribute]
  • Serialization and change of member name:
    <Member Name> is <Member Type> [, Serialize = <New Name>] [, xmlAttribute]
Versions 20 and later
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.
New in version 20
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.
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
// Serialized member
SerializedMember is int
// Non-serialized member
NonSerializedMember is string, Serialize = False  
// Member renamed during the serialization
RenamedMember is int, Serialize = "NewMemberName"
END
Note: To avoid serializing an array member, use the following syntax:
t is array <Serialize = False> of int
t2 is array <Serialize = "<serialization name>"> of int
Versions 20 and later

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:
<Class Name> is Class [, Serialize = <New Name>]
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Feature not available.
New in version 20

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:
<Class Name> is Class [, Serialize = <New Name>]
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Feature not available.

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:
<Class Name> is Class [, Serialize = <New Name>]
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Feature not available.

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.
  • Windows Mobile The XML serialization can only be performed in a Buffer variable.
  • Versions 20 and later
    Limits in psdXMLAggregated mode: the serialization/deserialization of advanced variables triggers an error at run time. The properties of the advanced variables are not serialized.
    New in version 20
    Limits in psdXMLAggregated mode: the serialization/deserialization of advanced variables triggers an error at run time. The properties of the advanced variables are not serialized.
    Limits in psdXMLAggregated mode: the serialization/deserialization of advanced variables triggers an error at run time. The properties of the advanced variables are not serialized.
  • stacks, queues, lists:
    • The JSON serialization of stacks, queues and lists is not available.
    • AndroidAndroid Widget Java You cannot serialize/deserialize the Queue, Stack or List variables.
  • Only the JSON serialization is available for the Record variables. No deserialization is possible.
Related Examples:
The Serialize/Deserialize functions Unit examples (WEBDEV): The Serialize/Deserialize functions
[ + ] This example explains how to use the WLanguage functions Serialize and Deserialize.
The serialization consists in saving a variable, an object, a structure, an array or any other element in a buffer. Then, this buffer can be saved on disk or sent by socket. This allows for the persistence of objects.
The Deserialize function is used to rebuild an object, an array or a structure from a buffer.
The Serialize/Deserialize functions Unit examples (WINDEV): The Serialize/Deserialize functions
[ + ] Using the WLanguage Serialize and Deserialize functions
The serialization consists in saving a variable, an object, a structure, an array or any other element in a buffer. Then, this buffer can be saved on disk or sent by socket. This allows for the persistence of objects.
The Deserialize function is used to rebuild an object, an array or a structure from a buffer.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230vm.dll
Windows Mobile wp230vm.dll
WEBDEV - Browser code WDJS.DLL
Java wd230java.jar
Linux wd230vm.so
Android wd230android.jar
Minimum required version
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment