Codec for Record-Jar records.

The record jar format uses %% to separate records. Each record is a set of key/value pairs.

The example below is an excerpt from the IANA Language Subtag Registry:

%%
Type: language
Subtag: ase
Description: American Sign Language
Added: 2009-07-29
%%
Type: language
Subtag: asf
Description: Auslan
Description: Australian Sign Language
Added: 2009-07-29

Usage

See the example in example/main.dart.

import 'package:betto_codec_recordjar/betto_codec_recordjar.dart';

const planetsJar = r'''
Planet: Mercury
Orbital-Radius: 57,910,000 km
Diameter: 4,880 km
Mass: 3.30e23 kg
%%
Planet: Venus
Orbital-Radius: 108,200,000 km
Diameter: 12,103.6 km
Mass: 4.869e24 kg
%%
Planet: Earth
Orbital-Radius: 149,600,000 km
Diameter: 12,756.3 km
Mass: 5.972e24 kg
Moons: Luna
''';

void main() {
  final data = recordJar.decode(planetsJar);
  for (var entry in data) {
    print(entry);
  }
}

Output:

{Planet: Mercury, Orbital-Radius: 57,910,000 km, Diameter: 4,880 km, Mass: 3.30e23 kg}
{Planet: Venus, Orbital-Radius: 108,200,000 km, Diameter: 12,103.6 km, Mass: 4.869e24 kg}
{Planet: Earth, Orbital-Radius: 149,600,000 km, Diameter: 12,756.3 km, Mass: 5.972e24 kg, Moons: Luna}

Additional information

Format is described in TAOUP: Raymond, E., "The Art of Unix Programming", 2003, isbn:0-13-142901-9.

An online version is available at: http://www.catb.org/~esr/writings/taoup/html/ch05s02.html#id2906931

Section 3 of RFC 5646 describes the use of the record-jar format in the IANA Language Subtag Registry.

See also: draft-phillips-record-jar.

Libraries

betto_codec_recordjar
Codec for Record-Jar records.