Skip to main content

Get Started

This document describes the JSON format understood by the sc_barcode_scanner_settings_new_from_json() function.

JSON Format

The top-level must always be a dictionary (object) containing one or more key-value pairs. In the simplest form, an empty dictionary can be passed to the function. This will return a default barcode scanner settings instance with all symbologies disabled. All other properties have their default value. In general, missing properties are left at their default value, so only the properties that need to be changed away from their default need to be specified. Key-value pairs not understood the by JSON parser are ignored as if they were not specified.

The following table shows the symbology names understood by the JSON parser:

Click to expand
SymbologyJSON Name (case is ignored)
ArUcoaruco
Australia Post 4Stateaustralian-post-4state
Aztecaztec
Codabarcodabar
Code 11code11
Code 128code128
Code 32code32
Code 39code39
Code 93code93
DataBar 14databar
DataBar Expandeddatabar-expanded
DataBar Limiteddatabar-limited
DataMatrixdata-matrix
DotCodedotcode
EAN13 / UPCAean13upca
EAN8ean8
Five-Digit-Add-Onfive-digit-add-on
French Post (La Poste)french-post
IATA 2of5iata2of5
Interleaved 2 of 5itf
KIXkix
LAPA 4SClapa4sc
Matrix 2of5matrix2of5
MaxiCodemaxicode
MicroPDF417micropdf417
Micro QRmicroqr
MSI-Plesseymsi-plessey
PDF417pdf417
QR Codeqr
Royal Mail 4Staterm4scc
Standard 2 of 5 (Code 25)code25
Two-Digit-Add-Ontwo-digit-add-on
UPCEupce
UPU 4Stateupu-4state
USPS Intelligent Mailusps-intelligent-mail

Symbology Settings

By default, all symbologies are disabled. To enable a symbology, it must be listed under the "symbologies" key. Symbologies can either be a dictionary, or an array of symbology names:

{
"symbologies" : [ "ean13upca", "ean8", "code128" ]
}

When using a dictionary, further symbology options can be specified, such as extensions to enable, used checksums etc.:

{
"symbologies" : {
"code128" : true,
"ean13upca" : {
"extensions" : ["remove_leading_upca_zero"]
},
"itf" : {
"checksums" : [ "mod10" ]
}
}
}

The following options are currently supported:

  • enabled: boolean indicating whether the symbology should be enabled. When using the dictionary form, enabled is automatically set to true.
  • colorInvertedEnabled: boolean indicating whether color-inverted codes of that symbology should be decoded. Default is false.
  • activeSymbolCounts: array of integers specifying the active symbol counts for the symbology. See sc_symbology_settings_set_active_symbol_counts for details.
  • extensions: Extensions to be enabled for the symbology.
  • checksums: List of optional checksums to use for the symbology.

Depending on the symbology, some of these properties are ignored. See Configure Barcode Symbologies for details.

Code Location and Search Area

tip

These options are not available when constructing the ScanSettings object for a barcode picker from JSON. Use areaSettingsPortrait, areaSettingsLandscape instead.

To customize the search area and code location hints, you can use the codeLocation1d, codeLocation2d, searchArea and codeDirectionHint properties.

Search Area

To customize the search area, set the searchArea property by defining the rectangle with x, y, width, and height.

{ 
"searchArea" : {
"x" : 0.0, "y" : 0.0, "width" : 1.0, "height" : 0.5
}
}

Code Location

To customize code location 1d and code location 2d, use the codeLocation1d and codeLocation2d properties. They consist of a rectangle, the area, and a constraint.

{ 
"codeLocation1d" : {
"area" : {"x" : 0.0, "y" : 0.0, "width" : 1.0, "height" : 0.5 },
"constraint" : "restrict" // or "hint"
}
}

Constraint must either be "restrict", or "hint".

Code Direction Hint

To customize the code direction hint, use the codeDirectionHint property.

{ 
"codeDirectionHint" : "left-to-right"
}

The code direction hint must either be "left-to-right", "right-to-left", "bottom-to-top", "top-to-bottom", "none", "vertical", or "horizontal".

Additional Properties

maxNumberOfCodesPerFrame sets the maximum number of codes per frame, see sc_barcode_scanner_settings_set_max_number_of_codes_per_frame(). codeDuplicateFilter sets the code duplicate filter, see sc_barcode_scanner_settings_set_code_duplicate_filter(). arucoDictionaryPreset sets the ArUco dictionary preset, see sc_aruco_dictionary_from_preset().