×
Namespaces

Variants
Actions
(Difference between revisions)

怎样解析JSON

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Addition to article of: Category:Windows Phone 7.5)
hamishwillee (Talk | contribs)
m (Hamishwillee - Fix categories)
 
Line 1: Line 1:
 +
[[Category:Lang-Chinese]][[Category:Code Examples]][[Category:Windows Phone 7.5]][[Category:Web Services on Windows Phone]][[Category:Files/Data on Windows Phone]][[Category:Symbian C++]][[Category:Qt]][[Category:JavaScript]]
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
 
|sourcecode= [[Media:S60-json-library.zip]]  
 
|sourcecode= [[Media:S60-json-library.zip]]  
Line 12: Line 13:
 
|language= Lang-Chinese
 
|language= Lang-Chinese
 
|translated-by= <!-- [[User:XXXX]] -->
 
|translated-by= <!-- [[User:XXXX]] -->
|translated-from-title= <!-- Title only -->
+
|translated-from-title= How to parse JSON string
 
|translated-from-id= <!-- Id of translated revision -->
 
|translated-from-id= <!-- Id of translated revision -->
 
|review-by= <!-- After re-review: [[User:username]] -->
 
|review-by= <!-- After re-review: [[User:username]] -->
Line 21: Line 22:
 
|author= [[User:WS YiLunLuo]]
 
|author= [[User:WS YiLunLuo]]
 
}}
 
}}
[[Category:Windows Phone]][[Category:Lang-Chinese]]
 
本文翻译自[[How to parse JSON string]]
 
  
 
JSON是很常见的一种格式。本文说明怎样在Symbian C++中解析JSON,并且提供link到有关Qt和Windows Phone的JSON解析的文章。
 
JSON是很常见的一种格式。本文说明怎样在Symbian C++中解析JSON,并且提供link到有关Qt和Windows Phone的JSON解析的文章。
Line 62: Line 61:
 
* [http://msdn.microsoft.com/en-us/library/bb412179.aspx Serialize and Deserialize JSON Data] - 微软的类
 
* [http://msdn.microsoft.com/en-us/library/bb412179.aspx Serialize and Deserialize JSON Data] - 微软的类
 
*  [http://json.codeplex.com/  json.net] - 开源的JSON解析类库
 
*  [http://json.codeplex.com/  json.net] - 开源的JSON解析类库
[[Category:Code Examples]][[Category:Windows Phone 7.5]]
 

Latest revision as of 07:59, 16 July 2013

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解析的文章。

[edit] 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;

[edit] JSON Parsing in Qt

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

[edit] JSON Parsing in Windows Phone 7

This page was last modified on 16 July 2013, at 07:59.
96 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.

×