AiorosXu / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

splitting the Json to Object into two pass #110

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To implement a json-rpc protocol, there are three steps.
First parse the json text to find the callee function and parameter types,
Second, based on type discoverd in first step, deseriallize sub-parts of 
json text into different object.
Third, convert result and other logging info into json.

gson only provided to object  to json  api, make it hard to do the first 
and third step.

This request to split the json to object into two pass.
1\ convert json text to json element tree.
2\ convert json element tree to object.

And split the object to json  into two pass.
1\ convert json element tree to object.
2\ convert json text to json element tree.

Is it possibel to add something like 
public JsonElement toJsonElement(Object src, Type typeOfSrc);
and
public JsonElement toJsonElement(string json);

Thanks.

I have a example.

Original issue reported on code.google.com by yufanyu...@gmail.com on 28 Mar 2009 at 1:20

Attachments:

GoogleCodeExporter commented 9 years ago
We explored making a change similar to this in 
http://code.google.com/p/google-gson/issues/detail?id=57 

We plan to release Gson 1.4 beta soon and in that we will provide a 
toJsonTree() or some similarly named 
method that will address this issue.

Original comment by inder123 on 28 Mar 2009 at 3:11

GoogleCodeExporter commented 9 years ago
Fixed in r420  by providing toJsonTree methods in Gson.

Original comment by inder123 on 3 Apr 2009 at 9:52