我使用了许多工具,例如 cJSON、nxjson 和 jsmn 解析器来解析 JSON 响应,但我使用的工具都没有以某种结构格式提供输出。下面是我在字符串中的 JSON 响应:
{"Code":1,"MSN":0,"HWID":7001,"Data":{"SignOffRequest":{"messageId":0,"barCodeReadErrorCnt":0,"markSenseReadErrorCnt":0,"markSenseValidationErrorCnt":0,"postPrintErrorCnt":0,"custTicketFeedErrorCnt":0,"custInputTicketJamsCnt":0,"keyStrokeCnt":0,"keyStrokeErrorCnt":0,"commCrcErrorCnt":0,"readTxnCnt":0,"keyedTxnCnt":0,"ticketMotionErrorCnt":0,"blankFeedErrorCnt":0,"blankTicketJamCnt":0,"startupNormalRespCnt":0,"startupErrorRespCnt":0,"primCommMesgSentCnt":0,"commRetransmitTxnCnt":0,"rawMessage":null,"TableUpdateNo":1,"FixtureUpdateNo":0}}}
我使用了 cJSON 工具,输出如下,它也是一个字符串:
{
"Code": 1,
"MSN": 0,
"HWID": 7001,
"Data": {
"SignOffRequest": {
"messageId": 0,
"barCodeReadErrorCnt": 0,
"markSenseReadErrorCnt": 0,
"markSenseValidationErrorCnt": 0,
"postPrintErrorCnt": 0,
"custTicketFeedErrorCnt": 0,
"custInputTicketJamsCnt": 0,
"keyStrokeCnt": 0,
"keyStrokeErrorCnt": 0,
"commCrcErrorCnt": 0,
"readTxnCnt": 0,
"keyedTxnCnt": 0,
"ticketMotionErrorCnt": 0,
"blankFeedErrorCnt": 0,
"blankTicketJamCnt": 0,
"startupNormalRespCnt": 0,
"startupErrorRespCnt": 0,
"primCommMesgSentCnt": 0,
"commRetransmitTxnCnt": 0,
"rawMessage": null,
"TableUpdateNo": 1,
"FixtureUpdateNo": 0
}
}
}
但我不想要上述格式的输出。我想要 C 结构形式的输出。是否可以在 C 结构中获得输出?