Skip to content

inspireui/json_editor

 
 

Repository files navigation

img

Features

  1. Support add comment;
  2. Support show errors for invalid json text;
  3. Pretty format json text;
  4. Output a custom json data model: JsonElement ;

Getting started

dependencies:
    json_editor: ^0.0.8

Screen Shot

Usage

import 'package:json_editor/json_editor.dart';

JsonEditor.string(
    jsonString: '''
        {
            // This is a comment
            "name": "young chan",
            "number": 100,
            "boo": true,
            "user": {"age": 20, "tall": 1.8},
            "cities": ["beijing", "shanghai", "shenzhen"]
         }
    ''',
    onValueChanged: (value) {
        print(value);
    },
)
import 'package:json_editor/json_editor.dart';

JsonEditor.object(
    object: const {
        "name": "young",
        "number": 100,
        "boo": true,
        "user": {"age": 20, "tall": 1.8},
        "cities": ["beijing", "shanghai", "shenzhen"]
    },
    onValueChanged: (value) {
        print(value);
    },
)

JsonElement is a data model witch contains key, value and comment.

import 'package:json_editor/json_editor.dart';

JsonEditor.element(
    element: JsonElement(),
    onValueChanged: (value) {
        print(value);
    },
)

Theme

If you want to custom the json theme. You can use JsonEditorTheme widget.

JsonEditorTheme(
    themeData: JsonEditorThemeData.defaultTheme(),
    child: JsonEditor.object(
        object: const {
            "name": "young",
            "number": 100,
            "boo": true,
            "user": {"age": 20, "tall": 1.8},
            "cities": ["beijing", "shanghai", "shenzhen"]
        },
        onValueChanged: (value) {
            print(value);
        },
    )
)

License

See LICENSE

Releases

No releases published

Packages

No packages published

Languages

  • Dart 73.0%
  • C++ 13.0%
  • CMake 9.8%
  • HTML 2.5%
  • C 0.9%
  • Swift 0.7%
  • Other 0.1%