title: Caused by: java.lang.NumberFormatException: Invalid double: "["5.0","5.0"]"
body: <p>I am integrating Citrus wallet in my company's app and am stuck on the following error.</p>
  
  <p>the stack trace:</p>
  
  <pre><code>java.lang.RuntimeException: An error occured while executing doInBackground()
  
                                                                        at         android.os.AsyncTask$3.done(AsyncTask.java:304)
                                                                       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                                                                       at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                       at java.lang.Thread.run(Thread.java:818)
                                                                    Caused by: java.lang.NumberFormatException: Invalid double: "["5.0","5.0"]"
                                                                       at java.lang.StringToReal.invalidReal(StringToReal.java:63)
                                                                       at java.lang.StringToReal.initialParse(StringToReal.java:164)
                                                                       at java.lang.StringToReal.parseDouble(StringToReal.java:282)
                                                                       at java.lang.Double.parseDouble(Double.java:301)
                                                                       at com.citrus.sdk.classes.Amount.getValueAsDouble(Amount.java:65)
                                                                       at com.citrus.sdk.payment.PaymentBill.&lt;init&gt;(PaymentBill.java:90)
                                                                       at com.citrus.sdk.payment.PaymentBill.fromJSON(PaymentBill.java:261)
                                                                       at com.citrus.sdk.GetJSONBill.doInBackground(GetJSONBill.java:70)
                                                                       at com.citrus.sdk.GetJSONBill.doInBackground(GetJSONBill.java:22)
                                                                       at android.os.AsyncTask$2.call(AsyncTask.java:292)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                                                                       at java.lang.Thread.run(Thread.java:818) 
  </code></pre>
  
  <p>This is the java code. The error occurs after Yes is clicked in the Dialog Box:</p>
  
  <pre><code>public class FragmentWallet extends DialogFragment implements View.OnClickListener {
  
  private Context mContext;
  private int balance = 1200;
  Button proceed;
  TextView textView;
  TextView log;
  TextView user_bal;
  CitrusClient citrusClient;
  Message text;
  Amount amount = new Amount("5.0");
  private String BILL_URL = "my_url"
  private WalletFragmentListener mListener;
  String msg;
  
  public FragmentWallet() {
  }
  
  public FragmentWallet(Context mContext) {
      this.mContext = mContext;
  }
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.wallet_screen, container, false);
  
      textView = (TextView) rootView.findViewById(R.id.user_email);
      log = (TextView) rootView.findViewById(R.id.logout);
      user_bal=(TextView) rootView.findViewById(R.id.user_balance);
  
      proceed = (Button) rootView.findViewById(R.id.proceed_citrus);
  
      msg = PaymentDialogFragment.getCitrusClientInstance().getUserEmailId();
  
      proceed.setOnClickListener(this);
      log.setOnClickListener(this);
      textView.setText(msg);
  
      return rootView;
  
  }
  
  @Override
  public void onClick(View v) {
      switch (v.getId()) {
          case R.id.proceed_citrus:
              onCreateDialog();
              break;
          case R.id.logout:
              onLogout();
              break;
      }
  }
  
  public void onCreateDialog() {
      AlertDialog.Builder builder1 = new AlertDialog.Builder(mContext);
      builder1.setMessage("Are you sure you want to proceed?");
      builder1.setCancelable(true);
  
      builder1.setPositiveButton(
              "Yes",
              new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                      //dialog.cancel();
                      payUsingNewCash();
                  }
              });
  
      builder1.setNegativeButton(
              "No",
              new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                      dialog.cancel();
                  }
              });
  
      AlertDialog alert11 = builder1.create();
      alert11.show();
  
  }
  
  private void payUsingNewCash() {
      Log.d("inside", "payUsingNewCash");
  
      checkBalance();
  
  }
  
  private void checkBalance() {
      Log.d("inside", "payUsingNewCash");
  
      PaymentDialogFragment.getCitrusClientInstance().getBalance(new Callback&lt;Amount&gt;() {
          @Override
          public void success(Amount amount) {
              //get balance amount . for now balance is hardcoded to 1200
              double bal=(Double)amount.getValueAsDouble();
               user_bal.setText("Your current balance is Rs."+bal);
              if (bal &gt;50) {
                  Toast.makeText(mContext,"balance is "+bal, Toast.LENGTH_LONG).show();
                  //proceed with payment
                  proceedWithPayment();
                  Log.d("inside", "payUsingNewCash");
              } else {
                  LoadMoney loadMoney=new LoadMoney(mContext);
                  FragmentManager fm=getFragmentManager();
                  loadMoney.show(fm,null);
              }
          }
  
          @Override
          public void error(CitrusError error) {
              Toast.makeText(mContext,"balance is not available. Please try again",Toast.LENGTH_LONG).show();
          }
      });
  }
  
  public void proceedWithPayment() {
      // Toast.makeText(mContext,"balance is not available. Please try again",Toast.LENGTH_LONG).show();
      Log.d("TAG","inside Proceed");
      try {
          Log.d("TAG","inside try");
  
          PaymentDialogFragment.getCitrusClientInstance().prepaidPay(new PaymentType.CitrusCash(amount,BILL_URL),new Callback&lt;PaymentResponse&gt;() {
  
  
              @Override
              public void success(PaymentResponse paymentResponse) {
                  Log.d("TAG","inside success");
                  Toast.makeText(mContext,"Successful",Toast.LENGTH_LONG).show();
              }
  
              @Override
              public void error(CitrusError citrusError) {
                  Log.d("TAG", citrusError.getMessage());
                  Toast.makeText(mContext,"Not successful.",Toast.LENGTH_LONG).show();
  
              }
          });Log.d("TAG","++");
      } catch (CitrusException e) {
          Log.d("Tag",e.toString());
          e.printStackTrace();
      }
      }
  
  public void onLogout(){
      getDialog().dismiss();
      PaymentDialogFragment.getCitrusClientInstance().signOut(new Callback&lt;CitrusResponse&gt;()
      {
          @Override
          public void success(CitrusResponse citrusResponse) {
              UserManagementFragment userManagementFragment = new UserManagementFragment(mContext);
              FragmentManager fm=getFragmentManager();
              userManagementFragment.show(fm,null);
          }
  
          @Override
          public void error(CitrusError error) {
  
          }
      });
  }
  }
  </code></pre>
  
  <p>The method Amount.getValueAsDouble():</p>
  
  <pre><code> public double getValueAsDouble() throws NumberFormatException {
      double value = 0.0D;
      if(!TextUtils.isEmpty(this.value)) {
          value = Double.parseDouble(this.value);
      }
  
      return value;
  }
  </code></pre>
  
  <p>The entire amount class:</p>
  
  <pre><code>public class Amount implements Parcelable {
  private final String value;
  private final String currency;
  public static final Creator&lt;Amount&gt; CREATOR = new Creator() {
      public Amount createFromParcel(Parcel source) {
          return new Amount(source, null);
      }
  
      public Amount[] newArray(int size) {
          return new Amount[size];
      }
  };
  
  public Amount(String value) {
      this.value = value;
      this.currency = "INR";
  }
  
  public Amount(String value, String currency) {
      this.value = value;
      this.currency = currency;
  }
  
  public String getValue() {
      return !TextUtils.isEmpty(this.value)?this.value.replaceFirst("^0+(?!$)", ""):this.value;
  }
  
  public String getCurrency() {
      return this.currency;
  }
  
  public String getValueAsFormattedDouble(String format) throws NumberFormatException {
      DecimalFormat df = new DecimalFormat(format);
      return df.format(this.getValueAsDouble());
  }
  
  public double getValueAsDouble() throws NumberFormatException {
      double value = 0.0D;
      if(!TextUtils.isEmpty(this.value)) {
          value = Double.parseDouble(this.value);
      }
  
      return value;
  }
  
  public static Amount fromJSON(String response) {
      Amount amount = null;
      JSONObject jsonObject = null;
      if(!TextUtils.isEmpty(response)) {
          try {
              jsonObject = new JSONObject(response);
              amount = fromJSONObject(jsonObject);
          } catch (JSONException var4) {
              var4.printStackTrace();
          }
      }
  
      return amount;
  }
  
  public static Amount fromJSONObject(JSONObject amountObject) {
      Amount amount = null;
      if(amountObject != null) {
          String value = amountObject.optString("value");
          String currency = amountObject.optString("currency");
          if(!TextUtils.isEmpty(value) &amp;&amp; !TextUtils.isEmpty(currency)) {
              amount = new Amount(value, currency);
          }
      }
  
      return amount;
  }
  
  public static String toJSON(Amount amount) {
      JSONObject billObject = toJSONObject(amount);
      return billObject != null?billObject.toString():null;
  }
  
  public static JSONObject toJSONObject(Amount amount) {
      JSONObject billObject = null;
      if(amount != null) {
          try {
              billObject = new JSONObject();
              billObject.put("value", amount.value);
              billObject.put("currency", amount.currency);
          } catch (JSONException var3) {
              var3.printStackTrace();
          }
      }
  
      return billObject;
  }
  
  public int describeContents() {
      return 0;
  }
  
  public void writeToParcel(Parcel dest, int flags) {
      dest.writeString(this.value);
      dest.writeString(this.currency);
  }
  
  private Amount(Parcel in) {
      this.value = in.readString();
      this.currency = in.readString();
  }
  
  public String toString() {
      return "Amount{value=\'" + this.value + '\'' + ", currency=\'" + this.currency + '\'' + '}';
  }
  
  public int hashCode() {
      return super.hashCode();
  }
  
  public boolean equals(Object o) {
      if(this == o) {
          return true;
      } else if(!(o instanceof Amount)) {
          return false;
      } else {
          Amount amount = (Amount)o;
          return this.getValueAsDouble() == amount.getValueAsDouble() &amp;&amp; this.currency.equalsIgnoreCase(amount.getCurrency());
      }
  }
  }
  </code></pre>
  
  <p>Any help will be highly appreciated</p>