how to get float value in json java
import java.math.BigDecimal; float mFloat = BigDecimal.valueOf(yourJSONobject.getDouble("double")).floatValue();
Here is what the above code is Doing:
1. It’s getting the double value from the JSON object.
2. It’s converting the double value to a BigDecimal.
3. It’s converting the BigDecimal to a float.