Json2proto is a command line tool for converting some json files to protobuf's proto file.
json2proto���Ѷ���洢json������ļ���Ϊ[ProtoBuf](https://developers.google.com/protocol-buffers/)��proto�ļ���
Solution
���������һ��json����
p0 : {
"x" : 0,
"y" : 1
}
�����[ProtoBuf](https://developers.google.com/protocol-buffers/)����ʾ�������Ϳ����������ģ�
message Position1 {
optional int8 x = 1;
optional int8 y = 2;
}
��Ȼ�����������Ҳ���ܴ洢��������, ֻ�Ƕ��˸������ֶ�, �ַ����ͷ�Χ����һЩ���ѡ�
message Position2 {
optional int32 x = 1;
optional int32 y = 2;
optional int32 z = 3;
}
���ͬʱҪ�洢p0�������p1����
p1 : {
x : 0,
y : 1,
z : 2.5
}
��ô��С(�����ֶΣ� ��С��Χ������)�Ŀ���ͬʱ�������������������Ӧ���������ģ�
message Position3 {
optional uint8 x = 1;
optional uint8 y = 2;
optional float z = 3;
}
json2protoͨ�������е������ֶ�_title�� ��ȷ����Щ��������ͬһ�����ͣ� ��������С����������Щ��������͡�
����û��_title�ֶεĶ��� json2proto����ͨ��-a�������Զ����շ���·������_title��
Usage: json2proto [options] file
Options:
-h, --help Display this information.
-v, --version Print the compiler version.
-o, --output Set the output file name.
-a, --auto Automatically generate a title for unnamed object.
-p, --prefix Set the class name prefix, default prefix is json2proto
-n, --namespace Set the namespace, default namespace is json2proto
-t, --title_tag Specify the title_tag for searching class name, default title is "_title".