TencentCloud / tencentcloud-iot-explorer-sdk-embedded-c

SDK for embedded system connect and comunicate with Tencent Cloud IoT Explorer Platform
Other
113 stars 52 forks source link

json解析存在bug, 无法解析开头带有空白字符的json字符串 #17

Open hacperme opened 2 years ago

hacperme commented 2 years ago

测试例子:

#include <stdio.h>
#include "lite-utils.h"

int main()
{
    char *    file_name;
    char *    ver;
    char *    file_type;

    char *line_buf = " \t\n {\"resource_name\":\"tts_mandarin_yw.pos\", \n\"version\":\"1.0.0\", \"resource_type\":\"FILE\"}";
    file_type = LITE_json_value_of("resource_type", line_buf);
    ver = LITE_json_value_of("version", line_buf);
    file_name = LITE_json_value_of("resource_name", line_buf);
    printf("line_buf:%s\n", line_buf);
    printf("file_type:%s\n", file_type);
    printf("ver:%s\n", ver);
    printf("file_name:%s\n", file_name);
    return 0;
}

结果:

line_buf:
 {"resource_name":"tts_mandarin_yw.pos",
"version":"1.0.0", "resource_type":"FILE"}
file_type:(null)
ver:(null)
file_name:(null)