b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

c 链表的定义和使用 cjson 源码阅读笔记(9)

电脑杂谈  发布时间:2017-12-31 09:23:46  来源:网络整理

解析对象和解析数组类似, 只不过对象的一个儿子是个 key-value, key 是字符串, value 可能是任何值, key 和 value 用 ":" 分隔。

/* Build an object from the text. */
static const char *parse_object(cJSON *item,const char *value) {
    cJSON *child;
    if (*value!='{') {
        ep=value;    /* not an object! */
        return 0;
    }
    item->type=cJSON_Object;
    value=skip(value+1);
    if (*value=='}') return value+1;/* empty array. */
    item->child=child=cJSON_New_Item();
    if (!item->child) return 0;
    value=skip(parse_string(child,skip(value)));
    if (!value) return 0;
    child->string=child->valuestring;
    child->valuestring=0;
    if (*value!=':') {
        ep=value;    /* fail! */
        return 0;
    }
    value=skip(parse_value(child,skip(value+1)));/* skip any spacing, get the value. */
    if (!value) return 0;
    while (*value==',') {
        cJSON *new_item;
        if (!(new_item=cJSON_New_Item()))return 0; /* memory fail */
        child->next=new_item;
        new_item->prev=child;
        child=new_item;
        value=skip(parse_string(child,skip(value+1)));
        if (!value) return 0;
        child->string=child->valuestring;
        child->valuestring=0;
        if (*value!=':') {
            ep=value;    /* fail! */
            return 0;
        }
        value=skip(parse_value(child,skip(value+1)));/* skip any spacing, get the value. */
        if (!value) return 0;
    }
    if (*value=='}') return value+1;/* end of array */
    ep=value;
    return 0;/* malformed. */
}


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-57098-9.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 吕同老
      吕同老

      就是将剩余的小包或者再买同批次的打开

    热点图片
    拼命载入中...