json_bigint 1.0.0+1 copy "json_bigint: ^1.0.0+1" to clipboard
json_bigint: ^1.0.0+1 copied to clipboard

A json serializer for dart that supports BigInt.

example/main.dart

import 'package:json_bigint/json_bigint.dart';

void main() {
  String json = '{"sometext": "hello world!", "bignumber": 9999999999999999999';

  // decoding
  var jsonMap = decodeJson(json) as Map<String, Object?>;
  print(jsonMap["sometext"]); //hello, world!
  print(jsonMap["bignumber"]); //9999999999999999999
  print(jsonMap["bignumber"] is BigInt); //true

  // encoding
  String jsonNew = encodeJson(jsonMap);
  print(jsonNew);
  //{"sometext": "hello world!", "bignumber": 9999999999999999999}

  // encoding w/ formatting
  EncoderSettings settings =
      EncoderSettings(indent: "  ", singleLineLimit: 30, afterKeyIndent: " ");

  String jsonFormatted = encodeJson(jsonMap);
  print(jsonFormatted);
  //{
  //  "sometext": "hello world!",
  //  "bignumber": 9999999999999999999
  //}
}
2
likes
130
points
288
downloads

Publisher

unverified uploader

Weekly Downloads

A json serializer for dart that supports BigInt.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

BSD-3-Clause (license)

Dependencies

collection, meta, petitparser

More

Packages that depend on json_bigint