一种Protobuf 到JSON 动态转换方法  被引量:2

A Dynamic Conversion Method from Protobuf to JSON

在线阅读下载全文

作  者:田丹 张金杰 李翀[2,3] 曲艳华 焦昊 Tian Dan;Zhang Jinjie;Li Chong;Qu Yanhua;Jiao Hao(Sinosteel Group Corporation Limited,Beijing 100180,China;Computer Network Information Center,Chinese Academy of Sciences,Beijing 100190,China;University of Chinese Academy of Sciences,Beijing 100049,China;Strategic Support Force Space Systems Division,Beijing 100094,China)

机构地区:[1]中国中钢集团有限公司,北京100180 [2]中国科学院计算机网络信息中心,北京100190 [3]中国科学院大学,北京100049 [4]战略支援部队航天系统部,北京100094

出  处:《数据与计算发展前沿》2020年第4期155-164,共10页Frontiers of Data & Computing

摘  要:【背景】Protobuf和JSON是目前两种主流网络数据结构,有着各自的特点和应用场景,随着互联网应用的场景复杂,不同场景下数据交换上有了新的要求。JSON主要应用于Web浏览器到服务器数据传输,Protobuf主要用于客户端到服务器端高效安全数据传输。【目的】若能实现两者的转换,可以促进数据交互,极大地提高开发效率。【方法】本文基于动态解析和类型反射技术,实现了Protobuf和JSON数据动态转换,并搭建测试平台和编写测试用例进行了验证。【结果】实验表明,该方法可靠稳定兼容性好,在测试用例不同测试数据下转换效率保持20MB/s,Protobuf 2和Protobuf 3均可正常转换。[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.

关 键 词:Protobuf JSON 转换 动态解析 类型反射 

分 类 号:TP311.12[自动化与计算机技术—计算机软件与理论]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象