Skip to content

Commit 7f1da17

Browse files
committed
🚑️ Rename jsond package to jsond_core and update imports across the project
1 parent 3033fa2 commit 7f1da17

28 files changed

+3310
-59
lines changed

README.md

Lines changed: 438 additions & 0 deletions
Large diffs are not rendered by default.

README_EN.md

Lines changed: 438 additions & 0 deletions
Large diffs are not rendered by default.

apps/jsond/README.md

Lines changed: 177 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,183 @@
1-
# jsond
1+
# JSON Dart App - Flutter 图形界面应用 (`jsond_app`)
22

3-
A new Flutter project.
3+
> 🌐 **语言版本**: [中文](README.md) | [English](README_EN.md)
44
5-
## Getting Started
5+
一个功能强大的 JSON 到 Dart 代码生成工具的 Flutter 图形界面应用。该应用提供了直观的用户界面,让开发者能够快速将 JSON 数据转换为 Dart 模型类。
66

7-
This project is a starting point for a Flutter application.
7+
## 🌟 主要功能
88

9-
A few resources to get you started if this is your first Flutter project:
9+
### 📝 JSON 输入支持
10+
- **实时解析**: 支持标准 JSON 和 JSON5 格式
11+
- **格式化功能**: 自动格式化和美化 JSON 内容
12+
- **Unicode 转义**: 支持 Unicode 字符串转换
13+
- **错误提示**: 详细的 JSON 语法错误提示
1014

11-
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12-
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
15+
### 🎨 多种内置模板
16+
- **With Final**: 生成带 final 修饰符的基础模型
17+
- **No Final**: 生成不带 final 修饰符的模型
18+
- **JsonSerializable**: 集成 json_annotation 包
19+
- **JsonSerializable With HiveCE**: 结合 Hive 数据库注解
20+
- **Freezed**: 使用 Freezed 包生成不可变模型
21+
- **Freezed With Default**: 带默认值的 Freezed 模型
22+
- **Freezed With HiveCE**: 结合 Hive 的 Freezed 模型
23+
- **Isar**: 支持 Isar 数据库的模型
24+
- **Isar + JsonSerializable**: Isar 与 json_annotation 结合
25+
- **Isar + Freezed**: Isar 与 Freezed 结合
1326

14-
For help getting started with Flutter development, view the
15-
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.
27+
### ⚙️ 自定义配置
28+
- **自定义模板**: 支持 Handlebars 语法的自定义模板编写
29+
- **对象命名**: 可自定义生成的类名
30+
- **主题系统**: 支持明亮/暗黑主题切换
31+
- **颜色主题**: 可自定义应用主题颜色
32+
- **代码格式化**: 集成 Dart 代码格式化工具
33+
34+
### 💻 跨平台支持
35+
- **桌面应用**: 支持 Windows、macOS、Linux
36+
- **移动应用**: 支持 Android、iOS
37+
- **Web 应用**: 支持浏览器运行
38+
39+
## 🚀 快速开始
40+
41+
### 安装依赖
42+
```bash
43+
# 克隆项目
44+
git clone https://github.com/iota9star/json_dart.git
45+
cd json_dart
46+
47+
# 安装依赖
48+
flutter pub get
49+
```
50+
51+
### 运行应用
52+
```bash
53+
# 运行 Flutter 应用
54+
flutter run
55+
```
56+
57+
### 使用步骤
58+
1. **输入 JSON**: 在左侧面板输入或粘贴 JSON 数据
59+
2. **选择模板**: 从内置模板中选择合适的代码风格
60+
3. **自定义名称**: 可选择性地为生成的类自定义名称
61+
4. **生成代码**: 右侧面板实时显示生成的 Dart 代码
62+
5. **复制代码**: 点击复制按钮将代码复制到剪贴板
63+
64+
## 🛠️ 模板语法
65+
66+
应用使用 Handlebars 模板语法,支持以下变量和助手函数:
67+
68+
### 对象级变量
69+
- `{{ obj_name }}`: 对象名称
70+
- `{{ obj_naming }}`: 对象命名
71+
- `{{ obj_custom_name }}`: 自定义对象名称
72+
- `{{ obj_fields_length }}`: 字段数量
73+
- `{{ obj_index }}`: 对象索引
74+
75+
### 字段级变量
76+
- `{{ field_key }}`: 字段键名
77+
- `{{ field_type }}`: 字段类型
78+
- `{{ field_type_name }}`: 字段类型名称
79+
- `{{ field_deser }}`: 反序列化代码
80+
- `{{ field_index }}`: 字段索引
81+
82+
### 助手函数
83+
- `{{# @pascal_case }}{{/ @pascal_case }}`: 帕斯卡命名
84+
- `{{# @camel_case }}{{/ @camel_case }}`: 驼峰命名
85+
- `{{# @constant_case }}{{/ @constant_case }}`: 常量命名
86+
- `{{# @snake_case }}{{/ @snake_case }}`: 下划线命名
87+
88+
### 条件判断
89+
- `{{# field_nullable }}{{/ field_nullable }}`: 字段可空
90+
- `{{# field_is_object }}{{/ field_is_object }}`: 字段是对象
91+
- `{{# field_is_array }}{{/ field_is_array }}`: 字段是数组
92+
- `{{# field_is_primitive }}{{/ field_is_primitive }}`: 字段是基础类型
93+
94+
## 📱 界面介绍
95+
96+
### 左侧模板面板
97+
- **内置模板列表**: 显示所有可用的内置模板
98+
- **自定义模板**: 管理用户创建的自定义模板
99+
- **模板操作**: 查看、编辑、删除、复制模板
100+
- **新建模板**: 创建自定义模板
101+
102+
### 中间 JSON 编辑器
103+
- **语法高亮**: JSON 语法高亮显示
104+
- **代码折叠**: 支持大型 JSON 的代码折叠
105+
- **快捷操作**: 格式化、转义、清空等操作按钮
106+
- **可调整宽度**: 拖拽分隔条调整编辑器宽度
107+
108+
### 右侧代码预览
109+
- **实时生成**: JSON 输入变化时实时生成代码
110+
- **语法高亮**: Dart 代码语法高亮
111+
- **自定义命名面板**: 可展开的对象命名自定义面板
112+
113+
### 设置面板
114+
- **主题模式**: 选择明亮、暗黑或跟随系统
115+
- **主题颜色**: 自定义应用主题色彩
116+
- **其他配置**: 各种个性化设置选项
117+
118+
## 🔧 技术特性
119+
120+
### 核心技术栈
121+
- **Flutter**: 跨平台 UI 框架
122+
- **jsond_core**: JSON 解析和代码生成核心库
123+
- **ANTLR4**: JSON5 解析器
124+
- **Hive**: 本地数据存储
125+
- **Mustache**: 模板引擎
126+
- **Code Builder**: Dart 代码生成
127+
128+
### 性能优化
129+
- **增量解析**: 只解析变化的 JSON 部分
130+
- **延迟渲染**: 大型代码块分片渲染
131+
- **内存管理**: 高效的内存使用策略
132+
133+
### 数据持久化
134+
- **模板存储**: 自定义模板持久化保存
135+
- **设置保存**: 用户偏好设置自动保存
136+
- **历史记录**: JSON 输入历史记录(可选)
137+
138+
## 🎯 使用场景
139+
140+
### API 开发
141+
- 快速将 API 响应转换为 Dart 模型
142+
- 支持复杂嵌套结构的解析
143+
- 自动生成序列化/反序列化代码
144+
145+
### 数据库建模
146+
- 为 Hive、Isar 等数据库生成模型
147+
- 支持关系型和文档型数据库注解
148+
- 自动处理类型转换
149+
150+
### 代码生成工具集成
151+
- 与 json_serializable、Freezed 等包集成
152+
- 支持 build_runner 工作流
153+
- 兼容现有代码生成工具链
154+
155+
## 🤝 贡献指南
156+
157+
我们欢迎社区贡献!请查看项目的贡献指南了解如何参与。
158+
159+
### 开发环境设置
160+
```bash
161+
# 安装 Flutter
162+
# 确保 Flutter SDK 版本 >= 3.32.6
163+
164+
# 克隆项目
165+
git clone https://github.com/iota9star/json_dart.git
166+
cd json_dart
167+
168+
# 获取依赖
169+
flutter pub get
170+
171+
# 运行测试
172+
flutter test
173+
```
174+
175+
## 📄 许可证
176+
177+
本项目使用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
178+
179+
## 🔗 相关链接
180+
181+
- [GitHub 仓库](https://github.com/iota9star/json_dart)
182+
- [问题反馈](https://github.com/iota9star/json_dart/issues)
183+
- [功能请求](https://github.com/iota9star/json_dart/discussions)

apps/jsond/README_EN.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
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)

apps/jsond/lib/internal/helpers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'dart:async';
22

3-
import 'package:jsond/jsond.dart';
3+
import 'package:jsond_core/core.dart';
44

55
Future<T> watchdog<T>(FutureOr<T> Function() action) async {
66
final s = Stopwatch()..start();

apps/jsond/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'package:flutter_highlight/themes/tomorrow.dart';
1313
import 'package:highlight/languages/handlebars.dart';
1414
import 'package:highlight/languages/json.dart';
1515
import 'package:hive_flutter/hive_flutter.dart';
16-
import 'package:jsond/jsond.dart';
16+
import 'package:jsond_core/core.dart';
1717
import 'package:recase/recase.dart';
1818
import 'package:sliver_tools/sliver_tools.dart';
1919
import 'package:universal_platform/universal_platform.dart';

0 commit comments

Comments
 (0)