Search packages, repositories and app categories

Package detailsv0.1.4

gson

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

30-day downloads
718
Likes
14
Pub points
40

Install package

flutter pub add gson

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Gson is a Dart package designed to parse and encode JSON data, specifically tailored to handle JSON structures generated by GSON, including complex formats like those used by Minecraft. It enables seamless serialization and deserialization of JSON into Dart objects, making it ideal for applications dealing with game data or structured JSON outputs. The package supports custom type adapters and flexible parsing strategies, ensuring compatibility with diverse JSON schemas. It is particularly useful in environments where precise control over JSON handling is required.

Use cases

  • Parsing Minecraft JSON data
  • Serializing complex object hierarchies
  • Handling dynamic JSON structures
  • Integrating with GSON-generated APIs
  • Custom JSON encoding/decoding

Key features

  • Supports GSON-compatible JSON
  • Flexible type adapters
  • Robust error handling
  • Extensible parsing logic
  • Lightweight and efficient

Suitable for

  • Game development projects
  • JSON-heavy backend integrations
  • Data transformation pipelines
  • Applications using Minecraft data formats
  • Developers needing fine-grained JSON control

Considerations

  • Limited platform support (no specified platforms)
  • Requires manual configuration for complex types
  • No built-in validation
  • Depends on external source code
  • Not optimized for large-scale JSON processing

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Forks Stargazers Issues BSD-2-Clause

dart-gson

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

This is just a simple parser and encoder.

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.6

And to import use

import 'package:gson/gson.dart';

Usage

To decode you can use

gson.decode("{...}");

and to decode you can use

gson.encode({...});

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

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

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

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)

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

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.