Syntax 2: for JSONGenerator objects
Description
Imports a JsonObjectItem item from a JSON file.
Applies to
Syntax
|
1 |
objectname.ImportFile ( long ParentItemHandle, string FileName ) |
|
1 |
objectname.ImportFile ( long ParentItemHandle, string Key, string FileName ) |
|
1 |
objectname.ImportFile ( string ParentItemPath, string FileName ) |
|
1 |
objectname.ImportFile ( string ParentItemPath, string Key, string FileName ) |
|
1 |
objectname.ImportFile ( string FileName ) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the JSONGenerator object in which you want |
|
ParentItemHandle |
A long whose value is the handle of the parent item of |
|
ParentItemPath |
A string whose value is the path of the parent item of |
|
Key |
A string whose value is the key of the child item |
|
FileName |
A string whose value is the name of a JSON file |
Return value
Long. Returns the handle of the new child item if it succeeds and
-1 if an error occurs. If any argument’s value is null, the method
returns null.
Example 1
This code example loads the string from the JSON file into the
array item of the JSONGenerator object:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Long ll_RootArray String ls_FileName, ls_Json JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator // Creates an array root item ll_RootArray = lnv_JsonGenerator.CreateJsonArray() //example.json contains {"id":1001, "name":"evan", "active":true} ls_FileName = "example.json" lnv_JsonGenerator.ImportFile(ll_RootArray, ls_FileName) //Result is [{"id":1001,"name":"evan","active":true}] ls_Json = lnv_JsonGenerator.GetJsonString() |
Example 2
This code example loads the string from the JSON file into the
object item of the JSONGenerator object:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Long ll_RootObject String ls_FileName, ls_Json JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator //Creates an object root item ll_RootObject = lnv_JsonGenerator.CreateJsonObject() //example.json contains {"id":1001, "name":"evan", "active":true} ls_FileName = "example.json" lnv_JsonGenerator.ImportFile(ll_RootObject, "Import", ls_FileName) //Result is {"Import":{"id":1001,"name":"evan","active":true}} ls_Json = lnv_JsonGenerator.GetJsonString() |
Example 3
This code example loads the string from the JSON file into the
array item of the JSONGenerator object:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
String ls_Path String ls_FileName, ls_Json JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator //Create an array root item lnv_JsonGenerator.CreateJsonArray() ls_Path = "/" // example.json contains {"id":1001, "name":"evan", "active":true} ls_FileName = "example.json" lnv_JsonGenerator.ImportFile(ls_Path, ls_FileName) //Result is [{"id":1001,"name":"evan","active":true}] ls_Json = lnv_JsonGenerator.GetJsonString() |
Example 4
This code example loads the string from the JSON file into the
object item of the JSONGenerator object:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
String ls_Path String ls_FileName, ls_Json JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator //Creates an object root item lnv_JsonGenerator.CreateJsonObject() ls_Path = "/" //example.json contains {"id":1001, "name":"evan", "active":true} ls_FileName = "example.json" lnv_JsonGenerator.ImportFile(ls_Path, "Import", ls_FileName) //Result is {"Import":{"id":1001,"name":"evan","active":true}} ls_Json = lnv_JsonGenerator.GetJsonString() |
Example 5
This code example imports the string from the JSON file as the
root item of the JSONGenerator object:
|
1 2 3 4 5 6 7 8 9 10 |
String ls_FileName, ls_Json JsonGenerator lnv_JsonGenerator lnv_JsonGenerator = Create JsonGenerator //num.json contains {"value":123.45,"value1":Infinity,"value2":-Infinity,"value3":NaN,"value4":null} ls_FileName = "num.json" lnv_JsonGenerator.ImportFile(ls_FileName) //Result is {"value":123.45,"value1":Infinity,"value2":-Infinity,"value3":NaN,"value4":null} ls_Json = lnv_JsonGenerator.GetJsonString() |
See also