Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 07:59, 16 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

怎样解析JSON

From Wiki
Jump to: navigation, search
WP Metro Icon File.png
WP Metro Icon Web.png
SignpostIcon WP7 70px.png
Article Metadata

代码示例
兼容于
文章
翻译:
最后由 hamishwillee 在 16 Jul 2013 编辑

JSON是很常见的一种格式。本文说明怎样在Symbian C++中解析JSON,并且提供link到有关Qt和Windows Phone的JSON解析的文章。

Symbian parsing library

Symbian C++的解析器叫做's60-json-library。它被放在这里,你可以在这里下载它:Media:S60-json-library.zip

下面的代码演示了怎样用这个API解析JSON,它解析了Google翻译返回的JSON数据。

_LIT(KTestFormatedJson, "{\"responseData\": {\"translatedText\":\"אני ילד\"}, \"responseDetails\": null, \"responseStatus\": 200}");
 
CJsonBuilder* jsonBuilder = CJsonBuilder::NewL();
// this will create json string representation in memory
jsonBuilder->BuildFromJsonStringL(iKTestFormatedJson);
 
CJsonObject* rootObject;
CJsonObject* textObj;
jsonBuilder->GetDocumentObject(rootObject);
 
if(rootObject)
{
TBuf<256> message;
rootObject->GetObjectL(_L("responseData"),textObj);
textObj->GetStringL(_L("translatedText"),message);
}
 
// we need manually release created object
delete rootObject;
 
// releases only jsonBuilder object, not objects which was created by him
delete jsonBuilder;

JSON Parsing in Qt

  • QJson - 在Qt中解析JSON的类库。

JSON Parsing in Windows Phone 7

This page was last modified on 16 July 2013, at 07:59.
97 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×