JSON反序列化与JSON解析在Android应用程序序列、化与、应用程序、JSON

2023-09-05 10:08:28 作者:拿你的真心爱我

什么是反序列化JSON的意思是,我在网上看到这个词。我不知道这个特殊的术语的含义。这将是巨大的,如果任何人都可以向我解释这是什么意思。

What does "deserializing Json" mean, I have seen this term on the Web. I don't know the meaning of this particular term. It would be great if anybody could explain to me what it means.

推荐答案

JSON是一个轻量级的基于文本的形式重新presenting数据的方法。例如,接触在电话簿的阵列可以被存储如下;

JSON is a method for representing data in a light-weight text-based form. For instance, an array of contacts in a phone book might be stored as follows;

{"contacts": [
  {"name": John, "phoneNumber":"+44000000000"},
  {"name": Jack, "phoneNumber":"+44000000001"}
]}

这是传输数据到网络服务时的主要​​目的是为了使用。这似乎是与REST特别受欢迎。

It's primary purpose is for use when transporting data to web-services. It seems to be especially popular with REST.

序列化数据以JSON是转向什么可能是在您的Java code一个阵列()到该数据的基于文本的重新presentation如上图所示的过程。反序列化JSON是相反的过程。在上面的例子中,反序列化的JSON是翻译文字上面显示成在Java应用程序的数据阵列的contactcs的过程

Serializing your data to JSON is the process of turning what might be an 'Array()' in your Java code into a text based representation of that data as shown above. De-Serializing JSON is that process in reverse. In the above example, Deserializing the JSON is the process of translating the text for the contactcs shown above into a data array in your Java application.

幸运的是,Android的SDK可以很容易地访问一个JSON库将处理完成这个过程。 http://developer.android.com/reference/org/json/JSONObject.html

Fortunately, the Android SDK makes it easy to access a JSON library that will handle this process for you. http://developer.android.com/reference/org/json/JSONObject.html

和以下GSON库,让生活更轻松。 http://sites.google.com/site/gson/gson-user-guide

And the following GSON library makes life even easier. http://sites.google.com/site/gson/gson-user-guide

有一堆休息与在网络上Android的例子,他们将几乎肯定能够帮助你。

There are a bunch of REST with Android examples on the web, they will almost definitely be able to help you out.

http://senior.ceng.metu.edu.tr/2009/praeda/2009/01/11/a-simple-restful-client-at-android/

http://www.josecgomez.com/2010/04/30/android-accessing-restfull-web-services-using-json/