On Fri, Apr 20, 2018 at 4:38 AM, Svetlin Zarev
<[email protected]> wrote:
> Hi,
>
> I have a YML file that looks like
>
> ---
> - NAME: example
> VERSION: 1.10
>
> The problem is that ObjectMapper.readValue(source, java.util.Map.class)
> treats the version as a floating point number, while it's not number at all
> and must be treated as String. This is a problem because it considers "1.1"
> to be the same as "1.10", which although is true for numbers is completely
> wrong when it comes to versions. So how can I configure ObjectMapper to
> treat everything as java.lang.String and to not try to guess the type ?
Enclose the value in quotes?
Or, use a POJO where type of `VERSION` property is `String`.
Use of `Map` will use whatever natural type would be, and I think
unquoted values that look like numbers
are to be taken as numbers.
And finally, you could also force use of String-valued Maps with
Map<String,String> values = mapper.readValue(source, new
TypeReference<Map<String,String>>() { });
I hope this helps,
-+ Tatu +-
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.