Ralf Sternberg

Results 55 comments of Ralf Sternberg

Wouldn't it be unexpected when `getInt("size", -1)` returns 23 for `{"size": 23}` but -1 for `{"size": 23.5}`?

Did you really get a `NumberFormatException` or an `UnsupportedOperationException`? I get the following trace: ``` java.lang.UnsupportedOperationException: Not a number: null at com.eclipsesource.json.JsonValue.asLong(JsonValue.java:329) at com.eclipsesource.json.JsonObject.getLong(JsonObject.java:577) ``` That's expected with the current...

> asString in the "JsonNumber" object not blowing up with a UnsupportedOperationException would already be an improvement You can call `toString` on a JsonNumber, which will return the JSON string...

Thanks @mafagafogigante for your insights, the distinction between a _default_ and a _fallback_ really nails it. I've been pondering with this issue, and I see the point of providing convenient...

Still there is a case that concerns me: ``` java String string = null; jsonObject.set("foo", string); ``` will accept `null` and set `"foo"` to `Json.NULL`. This was done for the...

This change has been made in 3e3918e. IIRC, this was done because the trailing `.0` can significantly inflate the created JSON without providing any additional information (`1.0 === 1` in...

> modify values without changing their types JSON defines the types _string_, _number_, _array_, _object_, and the literals `false`, `true`, and `null`. It does not differentiate between floating point and...

Even if the implementation was changed as suggested, you'd get `1.0` instead of `1.0000` ;-) Anyway, I see your point. The fractional digits may contain relevant information, e.g. the value's...

I can understand this requirement. There seem to be use cases for both modes, truncating and not truncating zeros. Maybe this should be configurable, e.g. `JsonValue.writeTo( writer, config )`? Could...

Maybe an additional `precision` or `format` parameter in the `valueOf` method could help?