How to serialize an object as a single value in Gson?
<p>When you have a class to be converted to a json, if it contains a BigDecimal attribute, it will return a json like this:</p>

<pre><code> Response {
       BigDecimal price;
 }
 //json:
 {
     price: 20.20
 }
</code></pre>

<p>Note that BigDecimal is a class. Its behavior is like an primitive (integer, float).</p>

<p>I want to produce the same behavior (a class return a single information to json)</p>

<p>Example:</p>

<pre><code>class Response {
    Money value
}

Money {
    BigDecimal price;
}

//What is returning:
{
    value : { price: 20.20 }
}

//What I want:
{
    value : 20.20
} 
</code></pre>