패키지, 저장소 및 앱 카테고리 검색

패키지 상세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 개

소스 저장소

이 패키지를 사용하는 프로젝트