JSON
What?
The JSON Extension Package for HALCON is an extension package meant to create, modify and parse JSON strings within the HDevelop
language.
Why?
The JSON Extension Package for HALCON brings advanced data structures to the HDevelop language.
Changes awkward procedure signatures like
OpenCamera (: : CamName, CamDevice, CamColorspace, CamBrightness, CamSaturation, CamBinning: AcqHandle)
ProcessImage (: : FilterMean, ThresholdMin, ThresholdMax, ScoreMin, NumMatches, MaxOverlap, SubPixel, NumLevels, Greediness, MinArea, MaxArea, CameraHandle: Result)
to concise
OpenCamera (: : JsonSettings: AcqHandle)
ProcessImage (: : JsonSettings, CameraHandle: Result)
This Extension Package also enables usage of persistent and human-readable configuration files which are compatible with modern web standards (Industry 4.0).
Details
The JSON Extension Package for HALCON is an extension package meant to create, modify and parse JSON strings within the HDevelop
language.
The JSON Extension Package provides additional operators to read and write JSON files.
The JSON string representation is a powerful and concise representation of structured data within a single string.
As the HDevelop scripting language is missing advanced structuring data types these scripts often contain
way too many variables and too many single parameters have to be pushed into procedure calls.
For example, the settings could be set with this JSON representation, either in a separate settings.json file
or directly set-up within the HDevelop script:
{
"camera": {
"brightness": 2,
"colorspace": "rgb",
"device": "Camera1",
"name": "DirectShow"
},
"filter": {
"mean": 7.5
}
}
Later, you can retrieve a certain value e.g. with a JSON pointer anywhere in your program:
json_pointer_tuple (JsonSettings, '/camera/name', CameraName)
Now, only a single JSON string has to be passed to procedures instead of the single parameters CameraBrightness,
CameraColorspace, CameraDevice, CameraName.
Please have a look at the HDevelop examples accompanying this extension package, too.
This extension package is based on the "JSON for Modern C++" library by Niels Lohmann, available at
https://github.com/nlohmann/json.
Currently, this Extension Package is available for HALCON 11.0, HALCON 12.0, and HALCON 13.0 and for Windows operating systems only.
Please contact json-extpack@heindl-solutions.com for assistance, purchasing, or bug reports.
Further information about the JSON Extension Package is available online at http://www.heindl-solutions.com/extpack/json.
Copyright Heindl Solutions, http://www.heindl-solutions.com
List of Operators
- json_array_sizeJsonArraySizeJsonArraySizejson_array_sizeJsonArraySizejson_array_size
- Returns the size/length of a JSON array.
- json_atJsonAtJsonAtjson_atJsonAtjson_at
- Extracts a JSON object at a given position from a JSON object or JSON array.
- json_at_tupleJsonAtTupleJsonAtTuplejson_at_tupleJsonAtTuplejson_at_tuple
- Parses a value or an array of values at a given position from a JSON object or JSON array.
- json_get_tupleJsonGetTupleJsonGetTuplejson_get_tupleJsonGetTuplejson_get_tuple
- Parses a value or an array of values from a JSON string.
- json_is_arrayJsonIsArrayJsonIsArrayjson_is_arrayJsonIsArrayjson_is_array
- Checks if a JSON-String is an array.
- json_is_booleanJsonIsBooleanJsonIsBooleanjson_is_booleanJsonIsBooleanjson_is_boolean
- Checks if a JSON-String is a boolean value.
- json_is_nullJsonIsNullJsonIsNulljson_is_nullJsonIsNulljson_is_null
- Checks if a JSON-String is null.
- json_is_numberJsonIsNumberJsonIsNumberjson_is_numberJsonIsNumberjson_is_number
- Checks if a JSON-String is a number.
- json_is_objectJsonIsObjectJsonIsObjectjson_is_objectJsonIsObjectjson_is_object
- Checks if a JSON-String is an object.
- json_is_primitiveJsonIsPrimitiveJsonIsPrimitivejson_is_primitiveJsonIsPrimitivejson_is_primitive
- Checks if a JSON-String is a primitive data type.
- json_is_stringJsonIsStringJsonIsStringjson_is_stringJsonIsStringjson_is_string
- Checks if a JSON-String is a string.
- json_is_structuredJsonIsStructuredJsonIsStructuredjson_is_structuredJsonIsStructuredjson_is_structured
- Checks if a JSON-String is structured.
- json_is_validJsonIsValidJsonIsValidjson_is_validJsonIsValidjson_is_valid
- Checks if a string is a valid JSON string.
- json_object_keysJsonObjectKeysJsonObjectKeysjson_object_keysJsonObjectKeysjson_object_keys
- Returns the keys of a JSON object.
- json_pointerJsonPointerJsonPointerjson_pointerJsonPointerjson_pointer
- Uses a JSON Pointer to extract a value from a JSON string.
- json_pointer_tupleJsonPointerTupleJsonPointerTuplejson_pointer_tupleJsonPointerTuplejson_pointer_tuple
- Uses a JSON Pointer to parse a value or an array of values from a JSON string.
- json_prettifyJsonPrettifyJsonPrettifyjson_prettifyJsonPrettifyjson_prettify
- Returns a prittified representation of a JSON string in a multivalue string tuple.
- json_read_fileJsonReadFileJsonReadFilejson_read_fileJsonReadFilejson_read_file
- Reads a JSON file into a JSON string.
- json_register_extpackJsonRegisterExtpackJsonRegisterExtpackjson_register_extpackJsonRegisterExtpackjson_register_extpack
- Registers this Extension Package for full commercial usage within a company.
- json_removeJsonRemoveJsonRemovejson_removeJsonRemovejson_remove
- Removes an entry in a JSON object or JSON array.
- json_set_jsonJsonSetJsonJsonSetJsonjson_set_jsonJsonSetJsonjson_set_json
- Sets a JSON string in a JSON object or JSON array.
- json_set_tupleJsonSetTupleJsonSetTuplejson_set_tupleJsonSetTuplejson_set_tuple
- Sets a tuple in a JSON object or JSON array.
- json_write_fileJsonWriteFileJsonWriteFilejson_write_fileJsonWriteFilejson_write_file
- Writes a JSON string into a text file.