搜尋套件、儲存庫與 APP 分類

套件詳情v0.1.4

gson

解析並編碼由 GSON 生成的 JSON(可解析 Minecraft 的 JSON)

近 30 天下載
718
喜歡數
14
Pub 分數
40

安裝套件

flutter pub add gson

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Gson 是一個 Dart 套件,專門用於解析和編碼 JSON 數據,特別針對由 GSON 產生的 JSON 結構進行優化,包括 Minecraft 使用的複雜格式。它能無縫地將 JSON 序列化和反序列化為 Dart 物件,非常適合處理遊戲資料或結構化 JSON 輸出的應用程式。該套件支援自訂類型適配器和彈性解析策略,確保與多樣化的 JSON 設計相容。在需要精確控制 JSON 處理的環境中尤為實用。

適用情境

  • 解析Minecraft JSON資料
  • 序列化複雜的物件層次結構
  • 處理動態 JSON 結構
  • 與 GSON 產生的 API 結合
  • 自訂 JSON 編碼/解碼

主要特色

  • 支援 GSON 相容的 JSON
  • 靈活的類型適配器
  • 強大的錯誤處理
  • 可擴充的解析邏輯
  • 輕量且高效

適合對象

  • 遊戲開發專案
  • JSON 豐富的後端整合
  • 資料轉換管道
  • 使用 Minecraft 資料格式的應用程式
  • 需要細粒度 JSON 控制的開發者

使用建議

  • 有限的平台支援(未指定平台)
  • 需要手動設定複雜類型
  • 無內建驗證
  • 依賴外部來源程式碼
  • 不適用於大規模 JSON 處理

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。