c++builder JSON

时间:2014-09-23 18:27:06   收藏:0   阅读:604
    TJSONArray* jar = (TJSONArray*)TJSONObject::ParseJSONValue(Memo3->Text);
    jar->Count;
    for (int i = 0; i < jar->Size(); i++)
    {

        TJSONValue *jv = jar->Get(i);
        jv = ((TJSONArray*)jv)->Get(1);
        TJSONPair *jp = (TJSONPair*)jv;
        jp->JsonString->Value();//值字段名
        jp->JsonValue->Value();//取值
        if (jp->JsonValue->Value() == "1") // 判断值
        {
            jar->Remove(i);
            break;
        }
    }
    // jar->Remove(1);
    Memo3->Text = jar->ToString();

    delete jar;

 

TJSONObject *JSON = (TJSONObject*)TJSONObject::ParseJSONValue(Memo2->Text);

TJSONArray* jArray = (TJSONArray*)JSON->Get("adverts")->JsonValue;

 TJSONObject* jCompanyInfo = (TJSONObject*)((TJSONObject*)jArray->Get(0))->Get("companyInfo")->JsonValue;
 String companyName = jCompanyInfo->Get("companyName")->JsonValue->Value();

 

原文:http://www.cnblogs.com/cb168/p/3988907.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!