title: Convert String to Double in Spring Expression Language
body: <p>I'm quite new to spring expression language. I have a map which contains values as string. </p>
  
  <pre><code>{
   "id": "1",
   "object": {
    "object1": {
      "fields": {
        "value1": {
           "value":"3"
        },
        "value2": {
           "value":"2"
        }
      }
    }
   }
  }
  </code></pre>
  
  <p>The spring expression that i have looks something like this,</p>
  
  <pre><code>((object['object1'].fields['value1'].value * object['object1'].fields['value2'].value) * 0.5)
  </code></pre>
  
  <p>My calculation method looks like this where SampleObject class has the map object</p>
  
  <pre><code>public Double calculation(String expression, SampleObject sampleObject){
      ExpressionParser parser = new SpelExpressionParser();
      Expression exp = parser.parseExpression(expression);
      Double evaluatedValue = (Double)exp.getValue(sampleObject);
      return evaluatedValue;
  }
  </code></pre>
  
  <p>Since the value is string, I get an error saying cannot convert String to Double. This can be eliminated if i change the expression like this</p>
  
  <pre><code>((new Double(object['object1'].fields['value1'].value) * new Double(object['object1'].fields['value2'].value)) * 0.5)
  </code></pre>
  
  <p>But I'm looking for a solution where I don't have to change the expression or the object. Is there a solution. </p>
  
  <p>Thanks in advance</p>