将C变量转换为JSON格式
我需要一个C程序,其中我的C字符串变量需要转换为JSON字符串变量。C程序中的字符串变量有: char mcode[20]=“123456” 我希望将上述值转换为JSON代码,如下格式所示:将C变量转换为JSON格式,c,json,C,Json,我需要一个C程序,其中我的C字符串变量需要转换为JSON字符串变量。C程序中的字符串变量有: char mcode[20]=“123456” 我希望将上述值转换为JSON代码,如下格式所示: { "mcode":"123456" , "bill": { "no": "0057", "customerId": "8989898", "name":"abc", "details": [{"category":"FMCG"
{
"mcode":"123456" ,
"bill": {
"no": "0057",
"customerId": "8989898",
"name":"abc",
"details": [{"category":"FMCG","amount":90000}, {"category":"Electronics","amount":45000}]
},
"total":135000
}
请帮助我查找C中的代码。您还没有提供任何代码来说明如何尝试(或失败)对这些变量进行JSON编码
我所能建议的就是一个C库,这样可以处理它的这一方面。在文章的底部有一个有用资源的列表
{
"mcode":"123456" ,
"bill": {
"no": "0057",
"customerId": "8989898",
"name":"abc",
"details": [{"category":"FMCG","amount":90000}, {"category":"Electronics","amount":45000}]
},
"total":135000
}