Question: I've asked this before for [Java](https://stackoverflow.com/questions/1395551/convert-a-string-to-object-in-java), but this applies specifically to J2ME. 

Is there a way in J2ME to convert a string, such as:

```
{"name":"MyNode", "width":200, "height":100}

```

to an internal *Object* representation of the same, in one line of code? 

---

The problem with such JSON libraries, is that they generate *JSONObjects* from strings, not plain *Objects*. My function requires an *Object*, so can I stuff down a *JSONObject* into it??

* Internal JSON classes such as [JSONObject](http://www.j2ee.me/developer/technicalArticles/javame/json-me/)
* [JSON-simple](http://code.google.com/p/json-simple/)

Answer: 
> 
> *The problem with such JSON libraries,
>  is that they generate JSONObjects from
>  strings, not plain Objects. My
>  function requires an Object, so can I
>  stuff down a JSONObject into it??*
> 
> 
> 

A "plain Object" (that is, an instance of the class `java.lang.Object`) cannot represent any state apart from its own identity. So what you are asking for is impossible.

On the other hand, all Java classes are implicitly subtypes of `java.lang.Object`, so any function that takes an `Object` parameter can be called with a `JSONObject` instance as argument ... assuming that `JSONObject` is a concrete Java class.
I think [Google Gson](http://code.google.com/p/google-gson/) does what you want. It does take a little bit more than just one line for setting things up, etc, but I've used it before in projects and it's a very useful conversion library.