Skip to content

Latest commit

 

History

History
59 lines (47 loc) · 1.68 KB

README.md

File metadata and controls

59 lines (47 loc) · 1.68 KB

Convert JSON to Protocol Buffer definition

npm version CI codecov dependencies Status devDependencies Status Maintainability

{
  "name": "Mo Kweon",
  "some_property": 1234
}

to

message Root {
  string name = 1;
  int64 some_property = 2;
}

Install

npm install -D json-to-protobuf-definition
yarn add -D json-to-protobuf-definition

How to use

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;
// }

How to develop

yarn # install dependencies
yarn test # run test
yarn lint # run lint or `yarn lint --fix` to fix the lint issues