パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.0.1

json2yaml

JSON データを YAML にレンダリングするための Dart パッケージで、組み込みの自動ビューティファイアと Dart の pubspec.yaml および pubspec.lock の規則をサポートしています

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
9.9万
いいね数
12
Pub ポイント
160

パッケージをインストール

flutter pub add json2yaml

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

JSONデータをYAML形式に変換し、自動フォーマットを行うDartパッケージです。Dartのpubspec.yamlおよびpubspec.lockファイルで使用される規則をサポートしており、設定や依存関係管理タスクに最適です。クリーンで読みやすい出力を保証し、複数のプラットフォームにおけるFlutterおよびDartプロジェクトへのシームレスな統合を実現します。

用途

  • JSON 設定を YAML に変換する
  • pubspec.yaml ファイルの生成
  • 依存関係マニフェストの解析とレンダリング
  • 設定ファイルの自動生成
  • JSON と YAML 形式間でのデータの同期

主な機能

  • YAML 出力の自動美化
  • pubspec.yaml および pubspec.lock の規約のサポート
  • flutter pub add を通じた簡単な統合
  • クロスプラットフォーム互換性
  • 軽量で効率的なパース
  • データ構造の整合性を保持する

適している対象

  • Dart および Flutter 開発者
  • CI/CD パイプラインの自動化
  • 構成管理
  • ツールおよびコード生成スクリプト
  • JSONからYAMLへの変換を必要とするプロジェクト

注意事項

  • 基本的な YAML 形式に制限されています
  • スキーマ検証なし
  • アンカーまたはエイリアスのような複雑なYAML機能を想定していません
  • 入力JSONの有効性に依存する
  • ネスト構造内のすべてのエッジケースをサポートしない可能性があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

json2yaml Build Status pubspec_lock version

Dart package to render JSON data to YAML:

  • Correct handling of nested structures
  • Built-in automatic beautifer
  • Supports Dart pubspec.yaml conventions
  • Compatible with conventions imposed by Dart pubspec.lock generator

Known limitations

  • Strings (single line and multiline) are always formatted as they are, without word wrapping for better human readability

json2yaml()

json2yaml is the function to format JSON data to YAML.

  const developerData = {
    'name': "Martin D'vloper",
    'job': 'Developer',
    'skill': 'Elite',
    'employed': true,
    'foods': ['Apple', 'Orange', 'Strawberry', 'Mango'],
    'languages': {
      'perl': 'Elite',
      'python': 'Elite',
      'pascal': 'Lame',
    },
    'education': '4 GCSEs\n3 A-Levels\nBSc in the Internet of Things'
  };

  print(json2yaml(developerData));

Advanced usage: YAML formatting styles

json2yaml supports the optional argument to customize YAML formatting for various use cases. At the moment, it supports the three following formatting styles:

  • YamlStyle.generic (default) -- Default formatting style applicable in most cases
  • YamlStyle.pubspecYaml -- YAML formatting style following pubspec.yaml formatting conventions
  • YamlStyle.pubspecLock -- YAML formatting style following pubspec.lock formatting conventions

YAML style is supplied as an optional argument to json2yaml():

/// Yaml formatting control options
enum YamlStyle {
  generic,
  pubspecYaml,
  pubspecLock,
}

/// Converts JSON to YAML representation
String json2yaml(
  Map<String, dynamic> json, {
  YamlStyle yamlStyle = YamlStyle.generic,
});

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト