gson 0.1.4 copy "gson: ^0.1.4" to clipboard
gson: ^0.1.4 copied to clipboard

Parses and encodes the json generated by GSON (Can parse minecraft's json)

dart-gson #

Parses and encodes the json generated by GSON (Can parse minecraft's json)

This is just a simple parser and decoder.

Website (github pages): https://miniminelp.github.io/dart-gson/

Repository (github): https://github.com/MinimineLP/dart-gson

View dart docs: https://miniminelp.github.io/dart-gson/doc/api/

View on pub: https://pub.dev/packages/gson

Installation #

Add this to your pubspec.yaml file

dependencies:
  gson: ^0.1.4
copied to clipboard

And to import use

import 'package:gson/gson.dart';
copied to clipboard

Usage #

To decode you can use

gson.decode("{...}");
copied to clipboard

and to decode you can use

gson.encode({...});
copied to clipboard

As dart has no different variable types for numbers (there are just num, int and double), the api gives you types. So if you want a double for example in the output you have to insert

gson.encode(new Double(1.0)); // >> 1.0d
copied to clipboard

Also the compiler gives these classes back to you, so you have to get the value property

gson.decode("1.0d").value; // >> 1.0
copied to clipboard

because booleans are displayed as bytes in gson, the boolean value is in the Byte type.

gson.encode(true) // >> 1b
gson.decode("1b").value // >> 1
gson.decode("1b").boolValue // >> true (and 0b will be false)
copied to clipboard

The program can't find the difference between the number 1 and true / the number 0 / false, because in the code it is the same.

For more examples see example/example.dart

License #

BSD 2-Clause License (See LICENSE)

Issues #

Please post issues here

14
likes
40
points
436
downloads

Publisher

unverified uploader

Weekly Downloads

2024.08.13 - 2025.02.25

Parses and encodes the json generated by GSON (Can parse minecraft's json)

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

BSD-2-Clause (license)

Dependencies

colorize

More

Packages that depend on gson