<p>In GWT, what is the best way to convert a JavaScriptObject overlay type into a JSON string?</p>

<p>I currently have</p>

<pre><code>public final String toJSON() {      
    return new JSONObject(this).toString();
}
</code></pre>

<p>Which seems to work fine. I would like to know if there are any better approaches.</p>

I've never actually tried that (only consumed JSON so far, never needed to produce it). This seems to be native browser/javascript functionality.
You
could
write it as:
```
```
public native String toJSON() /*-{
  return this.toString();
}-*/;
```
```
They essentially just do the exact same thing and likely result in identical JavaScript output. The optimizing compiler is really amazing.