|
| 1 | +# JSON Dart App - Flutter GUI Application (`jsond_app`) |
| 2 | + |
| 3 | +> 🌐 **Language**: [中文](README.md) | [English](README_EN.md) |
| 4 | +
|
| 5 | +A powerful Flutter GUI application for JSON to Dart code generation. This application provides an intuitive user interface that allows developers to quickly convert JSON data into Dart model classes. |
| 6 | + |
| 7 | +## 🌟 Key Features |
| 8 | + |
| 9 | +### 📝 JSON Input Support |
| 10 | +- **Real-time Parsing**: Support for standard JSON and JSON5 formats |
| 11 | +- **Formatting Functions**: Automatic formatting and beautification of JSON content |
| 12 | +- **Unicode Escaping**: Support for Unicode string conversion |
| 13 | +- **Error Messages**: Detailed JSON syntax error prompts |
| 14 | + |
| 15 | +### 🎨 Multiple Built-in Templates |
| 16 | +- **With Final**: Generate basic models with final modifiers |
| 17 | +- **No Final**: Generate models without final modifiers |
| 18 | +- **JsonSerializable**: Integrate with json_annotation package |
| 19 | +- **JsonSerializable With HiveCE**: Combined with Hive database annotations |
| 20 | +- **Freezed**: Generate immutable models using Freezed package |
| 21 | +- **Freezed With Default**: Freezed models with default values |
| 22 | +- **Freezed With HiveCE**: Freezed models combined with Hive |
| 23 | +- **Isar**: Models supporting Isar database |
| 24 | +- **Isar + JsonSerializable**: Isar combined with json_annotation |
| 25 | +- **Isar + Freezed**: Isar combined with Freezed |
| 26 | + |
| 27 | +### ⚙️ Custom Configuration |
| 28 | +- **Custom Templates**: Support for custom template writing with Handlebars syntax |
| 29 | +- **Object Naming**: Customizable generated class names |
| 30 | +- **Theme System**: Support for light/dark theme switching |
| 31 | +- **Color Themes**: Customizable application theme colors |
| 32 | +- **Code Formatting**: Integrated Dart code formatting tool |
| 33 | + |
| 34 | +### 💻 Cross-Platform Support |
| 35 | +- **Desktop Applications**: Support for Windows, macOS, Linux |
| 36 | +- **Mobile Applications**: Support for Android, iOS |
| 37 | +- **Web Applications**: Support for browser execution |
| 38 | + |
| 39 | +## 🚀 Quick Start |
| 40 | + |
| 41 | +### Install Dependencies |
| 42 | +```bash |
| 43 | +# Clone the project |
| 44 | +git clone https://github.com/iota9star/json_dart.git |
| 45 | +cd json_dart |
| 46 | + |
| 47 | +# Install dependencies |
| 48 | +flutter pub get |
| 49 | +``` |
| 50 | + |
| 51 | +### Run Application |
| 52 | +```bash |
| 53 | +# Run Flutter application |
| 54 | +flutter run |
| 55 | +``` |
| 56 | + |
| 57 | +### Usage Steps |
| 58 | +1. **Input JSON**: Enter or paste JSON data in the left panel |
| 59 | +2. **Select Template**: Choose appropriate code style from built-in templates |
| 60 | +3. **Custom Names**: Optionally customize class names for generated classes |
| 61 | +4. **Generate Code**: Right panel displays generated Dart code in real-time |
| 62 | +5. **Copy Code**: Click copy button to copy code to clipboard |
| 63 | + |
| 64 | +## 🛠️ Template Syntax |
| 65 | + |
| 66 | +The application uses Handlebars template syntax, supporting the following variables and helper functions: |
| 67 | + |
| 68 | +### Object-Level Variables |
| 69 | +- `{{ obj_name }}`: Object name |
| 70 | +- `{{ obj_naming }}`: Object naming |
| 71 | +- `{{ obj_custom_name }}`: Custom object name |
| 72 | +- `{{ obj_fields_length }}`: Number of fields |
| 73 | +- `{{ obj_index }}`: Object index |
| 74 | + |
| 75 | +### Field-Level Variables |
| 76 | +- `{{ field_key }}`: Field key name |
| 77 | +- `{{ field_type }}`: Field type |
| 78 | +- `{{ field_type_name }}`: Field type name |
| 79 | +- `{{ field_deser }}`: Deserialization code |
| 80 | +- `{{ field_index }}`: Field index |
| 81 | + |
| 82 | +### Helper Functions |
| 83 | +- `{{# @pascal_case }}{{/ @pascal_case }}`: Pascal case naming |
| 84 | +- `{{# @camel_case }}{{/ @camel_case }}`: Camel case naming |
| 85 | +- `{{# @constant_case }}{{/ @constant_case }}`: Constant case naming |
| 86 | +- `{{# @snake_case }}{{/ @snake_case }}`: Snake case naming |
| 87 | + |
| 88 | +### Conditional Statements |
| 89 | +- `{{# field_nullable }}{{/ field_nullable }}`: Field is nullable |
| 90 | +- `{{# field_is_object }}{{/ field_is_object }}`: Field is object |
| 91 | +- `{{# field_is_array }}{{/ field_is_array }}`: Field is array |
| 92 | +- `{{# field_is_primitive }}{{/ field_is_primitive }}`: Field is primitive type |
| 93 | + |
| 94 | +## 📱 Interface Introduction |
| 95 | + |
| 96 | +### Left Template Panel |
| 97 | +- **Built-in Template List**: Display all available built-in templates |
| 98 | +- **Custom Templates**: Manage user-created custom templates |
| 99 | +- **Template Operations**: View, edit, delete, copy templates |
| 100 | +- **New Template**: Create custom templates |
| 101 | + |
| 102 | +### Middle JSON Editor |
| 103 | +- **Syntax Highlighting**: JSON syntax highlighting display |
| 104 | +- **Code Folding**: Support for code folding of large JSON files |
| 105 | +- **Quick Actions**: Format, escape, clear and other action buttons |
| 106 | +- **Adjustable Width**: Drag separator to adjust editor width |
| 107 | + |
| 108 | +### Right Code Preview |
| 109 | +- **Real-time Generation**: Real-time code generation when JSON input changes |
| 110 | +- **Syntax Highlighting**: Dart code syntax highlighting |
| 111 | +- **Custom Naming Panel**: Expandable object naming customization panel |
| 112 | + |
| 113 | +### Settings Panel |
| 114 | +- **Theme Mode**: Choose light, dark, or follow system |
| 115 | +- **Theme Color**: Customize application theme colors |
| 116 | +- **Other Configurations**: Various personalization setting options |
| 117 | + |
| 118 | +## 🔧 Technical Features |
| 119 | + |
| 120 | +### Core Technology Stack |
| 121 | +- **Flutter**: Cross-platform UI framework |
| 122 | +- **jsond_core**: JSON parsing and code generation core library |
| 123 | +- **ANTLR4**: JSON5 parser |
| 124 | +- **Hive**: Local data storage |
| 125 | +- **Mustache**: Template engine |
| 126 | +- **Code Builder**: Dart code generation |
| 127 | + |
| 128 | +### Performance Optimization |
| 129 | +- **Incremental Parsing**: Parse only changed JSON parts |
| 130 | +- **Lazy Rendering**: Chunked rendering of large code blocks |
| 131 | +- **Memory Management**: Efficient memory usage strategy |
| 132 | + |
| 133 | +### Data Persistence |
| 134 | +- **Template Storage**: Persistent saving of custom templates |
| 135 | +- **Settings Storage**: Automatic saving of user preference settings |
| 136 | +- **History Records**: JSON input history records (optional) |
| 137 | + |
| 138 | +## 🎯 Use Cases |
| 139 | + |
| 140 | +### API Development |
| 141 | +- Quickly convert API responses to Dart models |
| 142 | +- Support for parsing complex nested structures |
| 143 | +- Automatically generate serialization/deserialization code |
| 144 | + |
| 145 | +### Database Modeling |
| 146 | +- Generate models for Hive, Isar and other databases |
| 147 | +- Support for relational and document database annotations |
| 148 | +- Automatic type conversion handling |
| 149 | + |
| 150 | +### Code Generation Tool Integration |
| 151 | +- Integrate with json_serializable, Freezed and other packages |
| 152 | +- Support build_runner workflow |
| 153 | +- Compatible with existing code generation toolchain |
| 154 | + |
| 155 | +## 🤝 Contributing Guide |
| 156 | + |
| 157 | +We welcome community contributions! Please check the project's contributing guide to learn how to participate. |
| 158 | + |
| 159 | +### Development Environment Setup |
| 160 | +```bash |
| 161 | +# Install Flutter |
| 162 | +# Ensure Flutter SDK version >= 3.32.6 |
| 163 | + |
| 164 | +# Clone project |
| 165 | +git clone https://github.com/iota9star/json_dart.git |
| 166 | +cd json_dart |
| 167 | + |
| 168 | +# Get dependencies |
| 169 | +flutter pub get |
| 170 | + |
| 171 | +# Run tests |
| 172 | +flutter test |
| 173 | +``` |
| 174 | + |
| 175 | +## 📄 License |
| 176 | + |
| 177 | +This project uses the MIT License - see the [LICENSE](LICENSE) file for details. |
| 178 | + |
| 179 | +## 🔗 Related Links |
| 180 | + |
| 181 | +- [GitHub Repository](https://github.com/iota9star/json_dart) |
| 182 | +- [Issue Reports](https://github.com/iota9star/json_dart/issues) |
| 183 | +- [Feature Requests](https://github.com/iota9star/json_dart/discussions) |
0 commit comments