GS1 Digital Link
Overview
The parser supports version 1.4.1 of the GS1 Digital Link standard for uncompressed URIs. The latest version of the Digital Link standard is described in GS1 Digital Link Standard: URI Syntax.
Sample usage for GS1 Digital Link parser and Barcode Capture
First, you need to create a DataCaptureContext, access a Camera and create GS1 parser:
var context = DataCaptureContext.forLicenseKey(SCANDIT_LICENSE_KEY);
var camera = Camera.defaultCamera;
if (camera != null) {
camera.applySettings(BarcodeCapture.recommendedCameraSettings);
context.setFrameSource(camera);
camera.switchToDesiredState(FrameSourceState.on);
}
var barcodeCaptureSettings = BarcodeCaptureSettings();
var barcodeCapture = BarcodeCapture.forContext(context, barcodeCaptureSettings);
var parser = Parser.forContextAndFormat(this.dataCaptureContext, ParserDataFormat.gs1DigitalLink);
Then, you need to implement BarcodeCaptureListener:
@override
void didScan(BarcodeCapture barcodeCapture, BarcodeCaptureSession session, Future<FrameData> getFrameData()) {
var barcode = session.newlyRecognizedBarcode;
var data = barcode?.data;
if (data == null) return;
parser.parseString(data).then((parsedData) {
// Extract the fields relevant to your use case. Below, for example, we extract a batch/lot number,
// which has the type String, and an expiry date, which is represented as a map with keys
// "year", "month", "day".
var serialNumber = parsedData.fieldsByName['10']?.parsed;
if (serialNumber == null) return;
var expiryDate = parsedData.fieldsByName['17']?.parsed as Map<String, dynamic>;
int year = expiryDate['year'];
int month = expiryDate['ymonthear'];
int day = expiryDate['day'];
// Do something with the extracted fields.
});
// Other callbacks omitted for brevity.
}
Finally, add the listener to the mode to receive scan results:
barcodeCapture.addListener(this);
For details, go to the API docs.
Examples
Parsing the following code (without the quotes):
"https://id.gs1.org/01/09506000134352/10/PX8L/21/1BAAAA2BB3?17=141100"
will result in the following JSON output:
[
{
"name" : "01",
"parsed" : {
"GTIN": "09506000134352"
},
"rawString" : "09506000134352"
},
{
"name" : "10",
"parsed" : "PX8L",
"rawString" : "PX8L"
},
{
"name" : "21",
"parsed" : "1BAAAA2BB3",
"rawString" : "1BAAAA2BB3"
},
{
"name" : "17",
"parsed" : {
"month" : 11,
"year" : 2014
},
"rawString" : "141100"
},
{ "name" : "humanReadableString",
"parsed" : "(01)09506000134352(10)PX8L(21)1BAAAA2BB3(17)141100",
"rawString" : "(01)09506000134352(10)PX8L(21)1BAAAA2BB3(17)141100",
}
]
Exposed Fields
The name of the fields correspond to the AI number. The following fields have their content parsed. Fields which are not in this list can still be accessed, but only the raw string is available.
“00”: parsed data is a dictionary, always contains alphanumeric subfields “extensionDigit” and “SSCC”.
“01”, “02”: parsed data is a dictionary, always contains “GTIN” field. It sometimes contains integer field “indicator” (if non-zero).
“10”: parsed data is a string (batch/lot number)
“11”, “12”, “13”, “15”, “16”, “17”: parsed data is a dictionary, always contains integer fields “year” (YYYY), “month” (MM) and sometimes “day” (DD)
“20”: parsed data is an integer (the variant)
“21”: parsed data is a string (the serial number)
“22”: parsed data is a string (consumer product variant)
“235”: parsed data is a string (third party controlled, serialised extension of global trade item number)
“240”: parsed data is a string (additional product identification assigned by the manufacturer)
“241”: parsed data is a string (customer part number)
“242”: parsed data is a string (made-to-Order variation number)
“243”: parsed data is a string (packaging component number)
“250”: parsed data is a string (secondary serial number)
“251”: parsed data is a string (reference to source entity)
“253”: parsed data is a string (global Document Type Identifier)
“254”: parsed data is a string (global Location Number)
“255”: parsed data is a string (global Coupon Number)
“30”: parsed data is an integer (count of items, between 0 and 99999999)
“31ab”, “32ab”, “33ab”, “34ab”, “35ab”, “36ab”, “39ab” for some numbers a and b: These AI’s are represented by two fields in our result: The field “31ab” and the fields “31ax”. For example: The AI “3222” has the fields “3222” and “322x” The parsed data is a string of the floating point number (e.g. “3202000150” has the parsed data “1.50”)
“37”: parsed data is an integer (count of items, between 0 and 99999999)
“400”: parsed data is a string (customer’s purchase order number)
“401”: parsed data is a string (global identification number for consignment)
“402”: parsed data is a string (global shipment identification number)
“403”: parsed data is a string (routing code)
“410”: parsed data is a string (ship to / deliver to global location number)
“411”: parsed data is a string (bill to / invoice to global location number)
“412”: parsed data is a string (purchased from global location number)
“413”: parsed data is a string (ship for / deliver for - forward to global location number)
“414”: parsed data is a string (identification of a physical location - global location number)
“415”: parsed data is a string (global location number of the invoicing party)
“416”: parsed data is a string (global location number of the production or service location)
“417”: parsed data is a string (party global location number)
“420”: parsed data is a string (ship to / deliver to postal code within a single postal authority)
“421”: parsed data is a dictionary, always contains “countryCode” and “postalCode” fields (ship to / deliver to postal code with three-digit ISO country code)
“422”: parsed data is a string (country of origin of a trade item / ISO 3166)
“423”: parsed data is an array (countries of initial processing / ISO 3166)
“424”: parsed data is a string (country of processing / ISO 3166)
“425”: parsed data is an array (countries of disassembly / ISO 3166)
“426”: parsed data is a string (country covering full process chain / ISO 3166)
“427”: parsed data is a string (country subdivision of origin code for a trade item / ISO 3166-2)
“4300”: parsed data is a string (ship-to / deliver-to company name)
“4301”: parsed data is a string (ship-to / deliver-to contact name)
“4302”: parsed data is a string (ship-to / deliver-to address line 1)
“4303”: parsed data is a string (ship-to / deliver-to address line 2)
“4304”: parsed data is a string (ship-to / deliver-to suburb)
“4305”: parsed data is a string (ship-to / deliver-to locality)
“4306”: parsed data is a string (ship-to / deliver-to region)
“4307”: parsed data is a string (ship-to / deliver-to country code)
“4308”: parsed data is a string (ship-to / deliver-to telephone number)
“4310”: parsed data is a string (return-to company name)
“4311”: parsed data is a string (return-to contact)
“4312”: parsed data is a string (return-to address line 1)
“4313”: parsed data is a string (return-to address line 2)
“4314”: parsed data is a string (return-to suburb)
“4315”: parsed data is a string (return-to locality)
“4316”: parsed data is a string (return-to region)
“4317”: parsed data is a string (return-to country code)
“4318”: parsed data is a string (return-to postal code)
“4319”: parsed data is a string (return-to telephone number)
“4320”: parsed data is a string (service code description)
“4321”: parsed data is a boolean (dangerous goods flag)
“4322”: parsed data is a boolean (authority to leave)
“4323”: parsed data is a boolean (signature required flag)
“4324”: parsed data is a dictionary, always contains integer fields “year” (YYYY), “month” (MM), “day” (DD), “hour” (HH), “minute” (MM) (not before delivery date time)
“4325”: parsed data is a dictionary, always contains integer fields “year” (YYYY), “month” (MM), “day” (DD), “hour” (HH), “minute” (MM) (not after delivery date time)
“4326”: parsed data is a dictionary, always contains integer fields “year” (YYYY), “month” (MM), “day” (DD) (release date)
“7001”: parsed data is a string (NATO stock number)
“7002”: parsed data is a string (UNECE meat carcasses and cuts classification)
“7003”: parsed data is a dictionary, always contains integer fields “year” (YYYY), “month” (MM), “day” (DD), “hour” (HH), “minute” (MM) (expiration date and time)
“7004”: parsed data is a string (active potency)
“7005”: parsed data is a string (catch area)
“7006”: parsed data is a dictionary, always contains integer fields “year” (YYYY), “month” (MM), “day” (DD) (first freeze date)
“7007”: parsed data is a string (harvest date)
“7008”: parsed data is a string (species for fishery purposes)
“7009”: parsed data is a string (fishing gear type)
“7010”: parsed data is a string (production method)
“7020”: parsed data is a string (refurbishment lot id)
“7021”: parsed data is a string (functional status)
“7022”: parsed data is a string (revision status)
“7023”: parsed data is a string (global individual asset identifier of an assembly)
“7030”-“7039””: parsed data is a string (number of processor with three-digit ISO country code)
“7040”: parsed data is a string (GS1 UIC with extension 1 and importer index)
“710”: parsed data is a string (national healthcare reimbursement number - Germany)
“711”: parsed data is a string (national healthcare reimbursement number - France)
“712”: parsed data is a string (national healthcare reimbursement number - Spain)
“713”: parsed data is a string (national healthcare reimbursement number - Brasil)
“714”: parsed data is a string (national healthcare reimbursement number - Portugal)
“715”: parsed data is a string (national healthcare reimbursement number - United States of America)
“7230”-“7239”: parsed data is a string (certification reference)
“8001”: parsed data is a string (Roll products (width, length, core diameter, direction, splices))
“8002”: parsed data is a string (Cellular mobile telephone identifier)
“8003”: parsed data is a string (Global Returnable Asset Identifier)
“8004”: parsed data is a string (Global Individual Asset Identifier)
“8005”: parsed data is a string (Price per unit of measure)
“8006”: parsed data is a string (Identification of an individual trade item)
“8007”: parsed data is a string (International Bank Account Number)
“8008”: parsed data is a string (Date and time of production)
“8009”: parsed data is a string (Optically Readable Sensor Indicator)
“8010”: parsed data is a string (Component/Part Identifier)
“8011”: parsed data is a string (Component/Part Identifier serial number)
“8012”: parsed data is a string (Software version)
“8013”: parsed data is a string (Global Model Number)
“8017”: parsed data is a dictionary, always contains string subfield “GSRN” (Global Service Relation Number to identify the relationship between an organisation offering services and the provider of services)
“8018”: parsed data is a dictionary, always contains string subfield “GSRN” (Global Service Relation Number to identify the relationship between an organisation offering services and the provider of services)
“8019”: parsed data is a string (Service Relation Instance Number)
“8020”: parsed data is a string (Payment slip reference number
“8026”: parsed data is a string (Identification of pieces of a trade item (ITIP) contained in a logistic unit)
“8110”: parsed data is a string (Coupon code identification for use in North America)
“8111”: parsed data is a string (Loyalty points of a coupon)
“8112”: parsed data is a string (Positive offer file coupon code identification for use in North America)
“90: parsed data is a string (information mutually agreed between trading partners)
“91”-“99”: parsed data is a string (company internal information)
Extensions
Arbitrary fields can be set using the url parameters, but no further parsing is performed by the parser. In this case, the (key, value) pairs are exposed directly as strings in the parsed results without further parsing.
Parser Options
Following options can be set to fine-tune the behavior of the parser:
- “strictMode”: boolean (default:false)
Controls the strictness of the parser. If true, only canonical URIs will be parsed and additionally the parsing of each field will follow the rules described for GS1 AI parsing.
- “outputHumanReadableString”: boolean (default: false)
Adds the additional field “humanReadableString” at the end of the resulting JSON string. This field contains the code in human readable form (i.e. AI number encapsulated in parenthesis).