21
A
答えて
39
我々はそのためgsonライブラリを使用しています。シリアル化はあなただけでJSONをシリアライズ(デ)にあなたのAndroidプロジェクト内の別のライブラリを使用しないようにしたい場合は、コードとして、以下の使用をCAU
new Gson().fromJson(jsonStr, MyClass.class);
18
、
new Gson().toJson(obj)
とデシリアライズのために呼び出すのと同じくらい簡単です私がやります。
JSONObject json = new JSONObject();
json.put("key", "value");
// ...
// "serialize"
Bundle bundle = new Bundle();
bundle.putString("json", json.toString());
をシリアル化すると、(デ)への単純なライブラリがあり
Bundle bundle = getBundleFromIntentOrWhaterver();
JSONObject json = null;
try {
json = new JSONObject(bundle.getString("json"));
String key = json.getString("key");
} catch (JSONException e) {
e.printStackTrace();
}
よろしく、マーティン
-1
protected void onPostExecute(String results) {
if (results!=null) {
try {
Tec tec_m=new Tec();
tec_m=new Gson().fromJson(results, Technician.class);
((AndroidActivity)activity).setData(tec_m);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
0
をデシリアライズするには、Android独自のJSONとの互換性がJSONを、シリアライズ
としょうかん。
// deserialize a java bean to json object
JSONObject studentJson = JsonDeer.toJson(student);
// serialize a java bean from json object
Student student1 = JsonDeer.fromJson(studentJson,Student.class);
関連する問題
- 1. Android HashMapシリアル化/逆シリアル化
- 2. 逆シリアル化JSON
- 3. JSONシリアル化WP7
- 4. 逆シリアル化JSON
- 5. クロスプラットフォームJSONシリアル化
- 6. カスタムオブジェクトのJSONシリアル化
- 7. カスタムJsonのシリアル化
- 8. SpidermonkeyのJSONシリアル化
- 9. JSONの逆シリアル化
- 10. SpringブートJSONシリアル化
- 11. ReactiveMongo JSONシリアル化ジェネリック
- 12. 逆シリアル化JSONリテラル
- 13. WebSocketシリアル化/デシリアライズjson
- 14. JSONイメジをシリアル化
- 15. スプレーJSONシリアル化インターフェイスタイプ
- 16. 逆シリアル化JSONオブジェクト
- 17. Androidでのシリアル化
- 18. redisノードライブラリリスト値のjsonシリアル化
- 19. JSON JAXBオブジェクト型のシリアル化
- 20. JSON逆シリアル化の問題
- 21. Jsonシリアル化の変更DataTime
- 22. ジャクソンカスタムブールjsonプロパティの逆シリアル化
- 23. Serde JSONのシリアル化エラー?
- 24. enumタイプのJSON逆シリアル化
- 25. Swift JSONのシリアル化エラー
- 26. ジャンクションのカスタムJSON逆シリアル化
- 27. 逆シリアル化JSONのジャクソン
- 28. C# - SNSのJSONシリアル化
- 29. C#Jsonインターフェイスのシリアル化
- 30. Jackson JSONのシリアル化マッピング
あなたはこのhttp://blog.brianbuikema.com/2010/04/android-how-to-deserialize-both-xml-and-json/ –
それがある可能性があり意味しました、ありがとう – Waypoint