PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Deserialization
  • Speed
  • 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
Deserialize (Function)
In French: Désérialise
Deserializes a buffer or a character string containing the data of a class, structure, array (including an associative array), queue, stack, list or advanced variable (gglCalendar for example) as well as their sub-elements.
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.
Example
// 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
Deserialize(<Variable> , <Buffer> , <Parameters>)
<Variable>: Type of variable
Structure, class, array, queue, list or stack variable.
  • For a structure or a class, this variable must be allocated.
  • For an array, a queue, a list or a stack, this variable is automatically allocated during the deserialization.
The deserialization will be performed in this variable.
<Buffer>: Ansi character string or buffer
Variable that contains the serialized data. A variable name must be specified.
<Parameters>: Integer constant
Type of deserialization (must correspond to the type chosen for the serialization):
psdBinaryBinary deserialization.
WEBDEV - Browser codeAndroidAndroid Widget JavaPHP The binary deserialization is not available.
Versions 17 and later
psdBinaryFormat16
New in version 17
psdBinaryFormat16
psdBinaryFormat16
Binary deserialization in 16 compatible format.
This format must be used if an application in version 17 must provide data to an application in version 16.
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
Deserialization in JSON format.
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 JSON serialization is now available.
New in version 20
AndroidAndroid Widget The JSON serialization is now available.
AndroidAndroid Widget The JSON serialization is now available.
psdXMLXML deserialization with reference to sub-objects.
Reminder: This type of serialization/deserialization allows you to use the XML format as storage and exchange modes between applications written in WLanguage.
WEBDEV - Browser code The deserialization in XML format is not available.
Versions 20 and later
psdXMLAggregated
New in version 20
psdXMLAggregated
psdXMLAggregated
XML deserialization with direct aggregation of sub-objects.
Note: The serialization in psdXMLAggregated mode allows you to easily generate an XML file in standard format, used to perform exchanges with other systems. The 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 deserialization mode is not available.
Remarks

Deserialization

The deserialization of an array, a queue or a stack deletes the content of the 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.
An advanced variable that was serialized with a French version of the product (and whose names and properties are in French in the serialization buffer) can be deserialized by an English version of the product (and conversely).
In the advanced variables:
  • the read-only properties cannot usually be deserialized.
  • the write-only properties cannot usually be serialized.
Special cases are noted in the documentation for each type.
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.

Speed

The binary deserialization is faster than the XML deserialization.

Limits

  • The fixed arrays and the associative arrays of local structures cannot be deserialized.
  • The global members of classes are not serialized/deserialized.
  • 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 class or structure 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 without mandatory parameter.
  • 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.
  • WEBDEV - Browser codeAndroidAndroid 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.
  • Managing the errors: Deserialize returns no error code. The ErrorOccurred variable is set to True if an error occurs.
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
Exemplo Deserialise - Json
Aula 1050 - WinDev - Json 001/... - Deserialise

// Nessa aula vou mostrar como retirar campos do Json

SAI_TextoJson=[
{"cep":"93410130","tipoDeLogradouro":"Rua","logradouro":"Paraiba","bairro":"Patria Nova","cidade":"Novo Hamburgo","estado":"RS"}
]


_cep_ is Structure
cep is string
tipoDeLogradouro is string
logradouro is string
bairro is string
cidade is string
estado is string
END
Estrutura_json is _cep_

Deserialize(Estrutura_json, SAI_TextoJson, psdJSON)

EDT_rua=Estrutura_json.logradouro
EDT_bairro=Estrutura_json.bairro
EDT_Cidade=Estrutura_json.cidade
EDT_Estado=Estrutura_json.estado
EDT_TipodeLogradouro=Estrutura_json.tipoDeLogradouro

//Blog com Video e Exemplo

http://windevdesenvolvimento.blogspot.com.br/2017/01/aula-1050-windev-json-001-deserialise.html

https://www.youtube.com/watch?v=-YGvpvKDgB8

http://forum.pcsoft.fr/pt-BR/pcsoft.br.windev/2089-aula-1050-windev-json-001-deserialise/read.awp
De matos
Jan. 28 2017