FasterXML / FasterXML/jackson-databind

`@JsonFormat` Support for locale specific number format

Open
#2,945 8 comments 4 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.7k
Forks
1.5k
Avg merge
3d 6h
Merged PRs (30d)
28

Description

**Describe the bug**
@JsonFormat does not work as expected when converting string to double and vice versa.

**Version information**
2.11.3

**To Reproduce**
I have an entity with a double property. Challenge is to read an external API that sends the capacity value as string in German Format.
```kotlin
@JsonIgnoreProperties(ignoreUnknown = true)
data class Event(
@JsonProperty("NUMCapacity")
@JsonFormat(shape = Shape.STRING, locale = "de_DE", pattern = "#.#")
var capacity: Double,
```

```
Caused by: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `double` from String "158,1": not a valid Double value; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `double` from String "158,1": not a valid Double value
```

**Expected behavior**
Expected behaviour is, when given the German locale, the comma is understood as the decimal separator.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.