Skip to content

lbeeon/json-to-protoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#Trans *.json to *.protoc

##How to use

  1. cp json_to_protoc.py

  2. Put *.json files in dir "json"

  3. Run "python json_to_protoc.py"

  4. Get *.protoc files in dir "protoc"

##Example Input

{
    "kind": "person",
    "fullName": "John Doe",
    "age": 22,
    "gender": "Male",
    "phoneNumber": {
        "areaCode": "206",
        "number": "1234567"
    },
    "children": [
        {
            "name": "Jane",
            "gender": "Female",
            "age": "6"
        },
        {
            "name": "John",
            "gender": "Male",
            "age": "15"
        }
    ],
    "citiesLived": [
        {
            "place": "Seattle",
            "yearsLived": [
                "1995"
            ]
        },
        {
            "place": "Stockholm",
            "yearsLived": [
                "2005"
            ]
        }
    ]
}

Output

message PersonData {
  required string kind = 1;
  required string gender = 2;
  required int64 age = 3;
  repeated CitiesLived citiesLived = 4;
  required PhoneNumber phoneNumber = 5;
  required string fullName = 6;
  repeated Children children = 7;
}

message Children {
  required string gender = 1;
  required string age = 2;
  required string name = 3;
}

message PhoneNumber {
  required string areaCode = 1;
  required string number = 2;
}

message CitiesLived {
  repeated string yearsLived = 1;
  required string place = 2;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages