Frontiers of Data and Computing ›› 2020, Vol. 2 ›› Issue (4): 155-164.doi: 10.11871/jfdc.issn.2096-742X.2020.04.013

• Technology and Applicaton • Previous Articles    

A Dynamic Conversion Method from Protobuf to JSON

Tian Dan1(),Zhang Jinjie2,3,*(),Li Chong2,3(),Qu Yanhua4,Jiao Hao4   

  1. 1. Sinosteel Group Corporation Limited, Beijing 100180, China
    2. Computer Network Information Center, Chinese Academy of Sciences, Beijing 100190, China
    3. University of Chinese Academy of Sciences, Beijing 100049, China
    4. Strategic Support Force Space Systems Division, Beijing 100094, China
  • Received:2020-07-06 Online:2020-08-20 Published:2020-09-10
  • Contact: Zhang Jinjie;


[Background] Two mainstream network data structures, Protobuf and JSON, have their own characteristics and application scenarios. With the growing complexity of network applications, data exchanges under different scenarios are required. In traditional, JSON is mainly used for data transmission from the Web browser to the server, while Protobuf is mainly for efficient and safe data transmission from clients to servers. [Objective] Thus, if the data format of JSON and Protobuf exchange can be achieved, it will promote data interactions and greatly improve development efficiency. [Methods] This article implements the dynamic data conversion method to convert Protobuf data to JSON format based on dynamic parsing and type reflection technologies. Besides, a test platform with multiple test cases for verifications has been built. [Results] Experiments show the proposed method is reliable and stable with good compatibility. The conversion capacity maintains at 20MB/s under different test data of the test cases for both Protobuf 2 and Protobuf 3.

Key words: Protobuf, JSON, conversion, dynamic analysis, type reflection