Deprecation warning

Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.

We are deprecating the 5.x API on all platforms (except Linux). Release 5.19 in April 2021 will be our final. Applications running 5.x will continue to work, and we will continue to release critical bug fixes and security patches only, for one year. We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.

You'll find the updated documentation at: Data Capture SDK Documentation for Android

Documentation for JavaScript

Usage Sample

Load the parser library with a script tag in the HTML file in which you want to use it:

<script src="path-to-folder-containing-parser-library/scandit-parser.js"></script>

Once this is done, you can use the parser library by calling ScanditParser.

The following code shows typical usage of the parser library.

var string = '+A123BJC5D6E71G';
var options = null;
try {
    var result = ScanditParser.parseString(
        ScanditParser.Type.HIBC,
        string,
        options
        );
} catch (e) {
    // Something went wrong
}

// We can directly access the json object ...
console.log(result.json);
// .. or we can acces individual fields by name
var field = result.getFieldByName("metadata");
console.log(field.parsed);
console.log(field.rawString);

Some data formats allow for special parsing options which modify the behaviour of the parser. These can be set by specifying them in the options object, e.g.:

options = {'outputHumanReadableString' : true};

Methods

class ScanditParser
parseString(dataFormat, string, options)

string is the string to be parsed, dataFormat may be ScanditParser.Type.HIBC, ScanditParser.Type.GS1AI, ScanditParser.Type.DLID, or ScanditParser.Type.MRTD, options is a JavaScript Object containing the parser options where the keys specify the respective option name.

Returns

An object result, which contains the properties result.json (raw json output of the parser library) and the method result.getFieldByName(name) which returns a field object {name:’…’, rawString:’…’, parsed:{…}}