{
"name": "Mo Kweon",
"some_property": 1234
}
to
message Root {
string name = 1;
int64 some_property = 2;
}
npm install -D json-to-protobuf-definition
yarn add -D json-to-protobuf-definition
import {
convertProtoMessageToString,
parseRootObjectToProtoMessage,
} from "json-to-protobuf-definition";
// obtained from JSON.parse('{"name": "Mark Hahn""}')
const input = {
name: "Mark Hahn",
};
const message = parseRootObjectToProtoMessage(input);
console.log(convertProtoMessageToString(message));
// message Root {
// string name = 1;
// }
yarn # install dependencies
yarn test # run test
yarn lint # run lint or `yarn lint --fix` to fix the lint issues