ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Type of import
  • Encoding
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
HJSONToRecord (Function)
In french: HJSONVersEnregistrement
HFSQL ClassicHFSQL Client/ServerAvailable only with these kinds of connection
Imports JSON data into the current record.
Example
let sString1 = "{ ""FirstName"":""Tintin"", ""FirstName"":[""Milou"", ""IDEFIX""] }"
let b1 = HJSONToRecord(Customer, sString1)
IF ErrorOccurred = True THEN
// Full message of the main error
Trace(HErrorInfo())
// Browse the sub-errors (if any)
FOR i = 1 _TO_ ErrorInfo(errNumberSubError)
// Full message of each sub-error
Trace("Sub-error " + i + ": " + ErrorInfo(errMessage, i))
END
END
HAdd(Customer)
Syntax
<Result> = HJSONToRecord(<Data file> , <JSON data> [, <List of items to import> [, <List of "items" to import>]])
<Result>: Boolean
  • True if no problems were encountered during the import process,
  • False otherwise. HErrorInfo returns more details about the problem.
<Data file>: Optional character string
Name of the HFSQL data file used. JSON data is imported into the current record.
<JSON data>: Character string) or JSON variable
JSON data to be converted to record. This data can correspond to a JSON string or to a JSON variable.
<List of items to import>: Optional character string
List of names of items in the data file into which the import will be performed. The names can be delimited by single quotes and are separated by commas or CR (Carriage Return) characters. The names of the composite key items, binary memo items and binary items are ignored.
The non-imported items will be initialized with their default value described in the analysis.
If this parameter is not specified or corresponds to an empty string (""), all items are imported (except compound keys, binary items and binary memos) in the order in which they were created in the physical file.
<List of "items" to import>: Optional character string
List of JSON item names to import. If this parameter is not specified or is an empty string (""), all JSON items are imported.
If an item remains is not found, a non-fatal error is returned.
Remarks

Type of import

If the list of items is specified: the import will find the "JSON items" with the same name as the items.
Example: The data file described in the analysis contains the following items: ITEM1, ITEM2, ... The JSON file must have the following structure:
{"File":
{
"Item1":Data of item 1,
"Item2":Data of item 2,
...
}
}
The names of items found in the JSON file that do not exist in the analysis or that are not specified in the list of items will be ignored during the import.
If the list of JSON items is not specified, the value of the JSON items is included in the item of the HFSQL data file that is named like the JSON item.

Encoding

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.
Example: for "é" (ASCII code 233, hexadecimal code E9), the encoding corresponds to "\u00E9".
Business / UI classification: Business Logic
Component: wd290hf.dll
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help