博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mochijson2和mochijson
阅读量:2058 次
发布时间:2019-04-29

本文共 794 字,大约阅读时间需要 2 分钟。

mochijson2:

编码  A = mochijson2:encode({struct, [{strKey, <<"strVal">>}, {intKey, 10}, {arrayKey, [1, 2, 3]}]}).

[123, [34,<<"abc">>,34],58,[34,<<"strVal">>,34],44,[34,<<"intKey">>,34],58,"10",44, [34,<<"arrayKey">>,34],58[91,"1",44,"2",44,"3",93],125]

123 <=> {  

34 <=> \"

58 <=> :

44 <=> ,

125 <=> }

整数,浮点数,字符串解析为字符串,原子解析为二进制字符串

解码  mochijson2:decode(A)

{struct,[{<<"strKey">>,<<"strVal">>},{<<"intKey">>,10}, {<<"arrayKey">>,[1,2,3]}]}

解码的时候无论key是什么都会被解析为二进制字符串,而value则是原来的值

 

 

 

mochijson:

编码:A = mochijson:encode({struct, [{strKey, <<"strVal">>}, {intKey, 10}, {arrayKey, [1, 2, 3]}]}).

[123,"\"strKey\"",58,"\"strVal\"",44,"\"intKey\"",58,"10",44,"\"arrayKey\"",58,[34,"\\u0001","\\u0002","\\u0003",34],125]

解码:mochijson:decode(A).

{struct,[{"strKey","strVal"},{"intKey",10},{"arrayKey",[1,2,3]}]}

 

 

 

 

 

转载地址:http://qxxlf.baihongyu.com/

你可能感兴趣的文章
C++ STL bind1st和bind2nd
查看>>
windows下Python安装requests
查看>>
目的:解决Ubuntu 使用gedit出现No protocol specified (gedit:14333):
查看>>
解决Ceph集群Mon和OSD网络变更或者ip(主要是mon)变换后,集群不能正常工作问题
查看>>
Python 格式化打印json数据(展开状态)
查看>>
解决windows下libcurl中curl_formadd()的CURLFORM_FILENAME使用中文导致post失败的问题
查看>>
Centos7 安装curl(openssl)和libxml2
查看>>
Centos7 离线安装RabbitMQ,并配置集群
查看>>
Centos7 or Other Linux RPM包查询下载
查看>>
运行springboot项目出现:Type javax.xml.bind.JAXBContext not present
查看>>
Java中多线程向mysql插入同一条数据冲突问题
查看>>
Idea Maven项目使用jar包,添加到本地库使用
查看>>
FastDFS集群架构配置搭建(转载)
查看>>
HTM+CSS实现立方体图片旋转展示效果
查看>>
FFmpeg 命令操作音视频
查看>>
问题:Opencv(3.1.0/3.4)找不到 /opencv2/gpu/gpu.hpp 问题
查看>>
目的:使用CUDA环境变量CUDA_VISIBLE_DEVICES来限定CUDA程序所能使用的GPU设备
查看>>
问题:Mysql中字段类型为text的值, java使用selectByExample查询为null
查看>>
程序员--学习之路--技巧
查看>>
解决问题之 MySQL慢查询日志设置
查看>>