FasterXML / FasterXML/jackson-databind

`@JsonFormat` Support for locale specific number format

Abierto
#2,945 8 comentarios 4 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Java
Estrellas
3.7k
Forks
1.5k
Merge medio
3 d 6 h
PR fusionados (30 d)
28

Descripción

**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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.