This tool provides an online JSON to Protobuf tool that supports nested parsing and array conversion of JSON data. This tool can accurately convert the JSON data structure into the Proto file format, handle complex data nesting and array elements, simplify the generation process of Proto files, and improve the conversion efficiency of the data model.
使用说明
Feature Introduction
- Supports parsing nested JSON strings, recursively parsing nested objects.
- Supports parsing array JSON strings, parsing the first JSON string in the array.
- Checks if the JSON string format is correct and outputs the error location.
- Supports generating comments.
Example
Parsing Nested JSON String
{
"name": "test", // Name
"age": 10, // Age
"addr": "Chengdu, Sichuan", // Address
"cls_info": [ // Classes
{
"name": "Basketball Class", // Class Name
"teacher": "Mr. Zhang" // Teacher
},
{
"name": "Art Class", // Class Name
"teacher": "Mr. Li" // Teacher
}
]
}
After processing:
message ClsInfo {
string name = 1; // Class Name
string teacher = 2; // Teacher
}
message GenerateObj {
string name = 1; // Name
int32 age = 2; // Age
string addr = 3; // Address
repeated ClsInfo cls_info = 4; // Classes
}
Directly Parsing Array JSON String
[
{
"name": "test",
"age": 10,
"addr": "Chengdu, Sichuan",
"cls_info": [
{
"name": "Basketball Class",
"teacher": "Mr. Zhang"
},
{
"name": "Art Class",
"teacher": "Mr. Li"
}
]
},
{
"name": "test2",
"age": 10,
"addr": "Chengdu, Sichuan",
"cls_info": [
{
"name": "Basketball Class",
"teacher": "Mr. Zhang"
},
{
"name": "Art Class",
"teacher": "Mr. Li"
}
]
}
]
After processing:
message GenerateObj {
string name = 1;
int32 age = 2;
string addr = 3;
repeated ClsInfo cls_info = 4;
}
message ClsInfo {
string name = 1;
string teacher = 2;
}