English 中文(简体)
2. 如何规定可以作文或笔记或XML的答复
原标题:How to parse a response which can be text or JSON or XML
  • 时间:2011-11-23 14:45:35
  •  标签:
  • java
  • xml
  • json

我试图与网站连接。 在认证成功之后,我收到了以下答复:

{"code": "OK", 
 "data": {"session_id": "[email protected]:EdiPNoBS2iYxOsAF9e2ceMbk"}, 
 "user": "[email protected]"}

通过上文(纯文本)的答复,可以迅速而容易地加以区别?

而且,如果答复是个JSON标的,那么我如何通过回应加以区别,最好是利用GSON图书馆? 我只想使用一个得到谷歌评估引擎支持的图书馆。

最后,如果与上述对应措施类似,那么我是否必须模仿上述对策? 同样,能否迅速而容易地通过这种对策和教化,最好是使用XML RPC客户? 同样,我只想利用一个得到“谷歌评估引擎”支持的图书馆。 XML RPC客户只是一个建议,如果你能够提出更好的建议的话。

最佳回答

我混淆了为什么你会回不同类型的对同一请求的答复。 然而,你应当能够检查复函的内容——Type的负责人,以确定你是否应该把它作为JSON或XML。 如你已经提到的那样,你可以使用Gson这样的图书馆来处理作为JSON的答复,或作为XMLAP(例如,日本宇宙航空研究开发机构)之一处理这种答复。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签