如何从JSON对象中移除包装器? [英] How do I remove a wrapper from a JSON Object?
问题描述
我有一个包装器的JSON对象,它包含有关它来自的服务的信息。在解析对象之前,我真正关心的是,我想取掉包装,然后解析对象。
I have a JSON object with a wrapper which contains information about the service it came from. Before parsing the object I really care about I would like to take off the wrapper and then just parse the object.
如何关闭此JSON对象:
How do I turn this JSON object:
{"object":{"id_object": 1, "description": "Black" }, "origin":"colors"}
进入:
Into this:
{"id_object": 1, "description": "Black"}
I我使用GSON作为JSON解析器,但是如果有任何其他会给我的功能,我可以改变这个库。
I am using GSON as JSON parser, but if any other will give me the functionallity, I can change the library.
预先感谢。
推荐答案
因为整个事情都是json的一块,所以解开它没有任何意义。只需解析整个事物,然后获取值的'对象'键,并从那里开始。
Since the whole thing is a blob of json, it doesn't make sense to 'unwrap it.' Just parse the whole thing, and and grab the value of the 'object' key, and go along from there.
这篇关于如何从JSON对象中移除包装器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!