Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Initialize a cHash object loading key/value pairs from a JSon string or file.

 

Syntax

 

<cHash>.FromJSon( [FILE] sJSonString)

 

Returns

 

None

 

Parameters

 

Name

Type

Optional

Meaning

sJSonString

String

No

A string containing a JSon buffer

 

If FILE modifier is specified, sJSonString is considered a file name whose content will be automatically loaded.

 

Remarks

 

Attention: cHash object will be erased before parsing new KeyName/Value pairs. All KeyName/Value pairs inside the object will be removed

 

Insert thinBasic code inside a key Value

 

It is possible to specify thinBasic code inside a JSon Value. If a value starts with $( and ends with ) it will be considered thinBasic code and interpreted in the fly.

 

Example: in the following JSon string Filename, RecordSeparator and StringDelimiter values are all included between $( and ) so they will be interpreted as thinBasic code and interpreted on the fly when <cOptions>.FromJSon will load them:

 

{
  "Filename": "$({APP_SourcePath + \"ADODB_Test_Export_Out.csv\"})",
  "AppendToFile": false,
  "ColumnNames": true,
  "RecordSeparator": "$({$crlf})",
  "StringDelimiter": "$({$dq})",
  "DecimalSeparator": ".",
  "RecordBuffer": 10,
  "Index": true,
  "IndexBase": 1,
  "IndexName": "Rec"
}

 

Restrictions

 

Structure of JSon buffer must be a flat structure with only one level of key/value pairs.

JSon String, Numeric, Boolean and Null JSon elements are supported.

JSon Arrays or objects are NOT supported.

 

See also

 

Examples

 
Dim ExportCsvOpt as new cHash

 
String JSonFileName     = App_SourcePath + "jsonConfigFile.json"
String JSonStringBuffer = "{ ""Index"": true, ""IndexBase"": 1, ""IndexName"": ""Rec""}"

 
ExportCsvOpt.FromJSon(File_Load(JSonFileName))

ExportCsvOpt.FromJSon(File JSonFileName)

ExportCsvOpt.FromJSon(JSonStringBuffer)

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software