Scandit Parser Library

The Scandit Parser Library parses data strings, e.g. as found in barcodes, into a set of key-value mappings. These data formats are supported: Health Industry Bar Code (HIBC), GS1 Application Identifier (AI) system, and AAMVA Driver License/Identification. Currently there are bindings for Android and iOS available.

More binding languages and data formats will be added in future releases. Please contact us if the data format you are using is not supported by the library, or you want to use the Scandit Parser Library on a yet-unsupported platform.

Interested in using the library in your project? Contact us.

Quick Start Guide

Installation: Follow these instructions for how to add the Scandit Parser Library to your project.

In a nutshell, the Scandit Parser Library provides functionality to transform a data string and into a list of key-value pairs. To use this functionality in your app, first the parser must be instantiated with the desired format. The result is then returned in a result object. The following two samples show how the parser code typically looks like on Android and iOS.

Android Example:

import com.scandit.parser.*;
import org.json.*;
import java.util.HashMap;

...
...

Parser parser = new Parser(DataFormat.HIBC);

ParserResult res = null;
try {
    res = parser.parseString("+A99912345/$$52001510X33");
} catch (IllegalArgumentException e) {
    // Something went wrong.
}


// We can either acces the data from the raw JSON string ...
Log.d(TAG, res.getJsonString());

// ... or from the fields dictionary ...
HashMap<String, Field> map = res.getFieldsDict();
Field metaField = map.get("metadata");
Log.d(TAG, metaField.getRaw());
// parsed can be a Map<String,Object>, Object[], Integer, Long, Boolean, Double or String
Object parsed = metaField.getParsed();
Log.d(TAG, metaField.getRaw());
Log.d(TAG, parsed.toString());

// ... or from the fields array
Field[] fields = res.getFieldsArray();
for (int i = 0; i < fields.length; i++) {
    Log.d(TAG, fields[i].getName());
    Log.d(TAG, fields[i].getRaw());
    Object p = fields[i].getParsed();
    Log.d(TAG, p.toString());
}

For details, go to the Android API docs.

iOS Example:

#import <ScanditParser/ScanditParser.h>

...

// Replace SPLDataFormatHIBC with the data format of your choice.
SPLParser *parser = [[SPLParser alloc] initWithDataFormat:SPLDataFormatHIBC];
NSError *err;
SPLParserResult *result = [parser parseString:@"+A99912345/$$52001510X33" error:&err];
if (!result) {
    // Something went wrong. Look at err for more info.
}

// We can either access the data from the raw JSON string...
NSLog(@"%@", result.jsonString);

// ... or from the fields dictionary...
NSDictionary<NSString*, SPLField*> *fieldsDictionary = result.fieldsDict;
for (NSString *key in fieldsDictionary.allKeys) {
    SPLField *field = [fieldsDictionary objectForKey:key];
    NSLog(@"%@ name: %@", key, field.name);
    NSLog(@"%@ raw: %@", key, field.rawString);
    NSLog(@"%@ parsed: %@", key, field.parsed);
}

// ... or from the fields array
for (SPLField* field in result.fieldsArray) {
    NSLog(@"%@ raw: %@", field.name, field.rawString);
    NSLog(@"%@ parsed: %@", field.name, field.parsed);
}

For details, go to the iOS API docs.

Format-Specific Documentation