Pakete, Repositories und App-Kategorien suchen

Paketdetailsv3.0.1

json2yaml

Dart-Paket zum Rendern von JSON-Daten in YAML mit integriertem automatischen Beautifier und Unterstützung für Dart pubspec.yaml- und pubspec.lock-Konventionen

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
98.700
Likes
12
Pub-Punkte
160

Paket installieren

flutter pub add json2yaml

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Ein Dart-Paket, das JSON-Daten in YAML-Format mit automatischer Formatierung konvertiert. Es unterstützt die Konventionen, die in den Dateien pubspec.yaml und pubspec.lock von Dart verwendet werden, und ist daher ideal für Konfigurations- und Abhängigkeitsverwaltungsaufgaben geeignet. Das Paket sorgt für saubere, lesbare Ausgabe und lässt sich nahtlos in Flutter- und Dart-Projekte auf mehreren Plattformen integrieren.

Anwendungsfälle

  • JSON-Konfigurationen in YAML konvertieren
  • Erstellen von pubspec.yaml-Dateien
  • Analyse und Darstellung von Abhängigkeitsmanifesten
  • Automatisierung der Konfigurationsdateierstellung
  • Synchronisieren von Daten zwischen JSON und YAML-Formaten

Hauptmerkmale

  • Automatische Verschönerung der YAML-Ausgabe
  • Unterstützung für Pubspec.yaml- und Pubspec.lock-Konventionen
  • Einfache Integration über flutter pub add
  • Plattformübergreifende Kompatibilität
  • Leichtgewichtiges und effizientes Parsen
  • Erhält die Integrität der Datenstruktur

Geeignet für

  • Dart- und Flutter-Entwickler
  • CI/CD-Pipeline-Automatisierung
  • Konfigurationsmanagement
  • Tooling und Codegenerierungsskripte
  • Projekte, die eine JSON-zu-YAML-Konvertierung erfordern

Hinweise

  • Beschränkt auf grundlegendes YAML-Format
  • Keine Schemaüberprüfung
  • Nicht für komplexe YAML-Funktionen wie Anchors oder Aliase ausgelegt
  • Abhängig von der Gültigkeit des Eingabe-JSON
  • Unterstützt möglicherweise nicht alle Randfälle in verschachtelten Strukturen

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

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,
});

Kategorien

Abhängigkeiten

Abhängigkeiten 1 Einträge

Quell-Repository

Projekte, die dieses Paket verwenden