Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个字符串,其中包含:
{"ticker":{"high":8.976,"low":8.843,"avg":8.9095,"vol":2096.78,"last":8.845,"buy":8.946,"sell":8.843,"server_time":1343686701}}
我将如何获取这些数字并将它们放入一个单独的变量中?
例如 :
int high = 8.976 int low = 8.843 /* and so on */
很多方法。
“sscanf”是一种选择。
标准字符串函数“strstr()”、“atof()”等是另一个。
我建议找到一个好的 JSON 解析库。例如: