Advertisement
hazer_hazer

Untitled

Nov 17th, 2019
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. from json2protobuf import Lexer
  2. from json2protobuf import Parser
  3. from json2protobuf import Converter
  4.  
  5. def json2pb(json):
  6.  
  7.     try:
  8.         lexer = Lexer.Lexer(json)
  9.         tokens = lexer.lex()
  10.         parser = Parser.Parser(tokens)
  11.         obj = parser.parse()
  12.         converter = Converter.Converter(obj)
  13.         pb = converter.convert()
  14.  
  15.         return pb
  16.     except Exception as error:
  17.         print(error)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement