ejson 0.3.1 ejson: ^0.3.1 copied to clipboard
EJSON serialization. BSON is a binary format used to store JSON-like documents efficiently. EJSON extends JSON defining how all BSON types should be represented in JSON.
// Copyright 2024 MongoDB, Inc.
// SPDX-License-Identifier: Apache-2.0
import 'dart:convert';
import 'package:ejson/ejson.dart';
import 'package:test/test.dart';
void main() {
test('round-trip', () {
final value = {
'abe': [1, 4],
'kat': <int>[],
};
final encoded = toEJson(value);
final json = jsonEncode(encoded);
print(json);
final decoded = fromEJson<Map<String, List<int>>>(jsonDecode(json));
expect(value, decoded);
});
}