v1.4 LocalDate support
This commit is contained in:
parent
06a15f3feb
commit
b3687452f6
5 changed files with 29 additions and 6 deletions
|
|
@ -5,12 +5,12 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>nl.sander</groupId>
|
<groupId>nl.sander</groupId>
|
||||||
<artifactId>jsonthingy-pom</artifactId>
|
<artifactId>jsonthingy-pom</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<name>JsonToy-JMH</name>
|
<name>JsonToy-JMH</name>
|
||||||
<artifactId>jsonthingy-jmhtests</artifactId>
|
<artifactId>jsonthingy-jmhtests</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>nl.sander</groupId>
|
<groupId>nl.sander</groupId>
|
||||||
<artifactId>jsonthingy-pom</artifactId>
|
<artifactId>jsonthingy-pom</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<name>JsonToy</name>
|
<name>JsonToy</name>
|
||||||
<artifactId>jsonthingy</artifactId>
|
<artifactId>jsonthingy</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
|
@ -80,7 +82,7 @@ public class Mapper {
|
||||||
b.append("\"");
|
b.append("\"");
|
||||||
Mapper.escape(b, (Character) value);
|
Mapper.escape(b, (Character) value);
|
||||||
b.append("\"");
|
b.append("\"");
|
||||||
} else if (type == UUID.class || type.isEnum()) {
|
} else if (type == UUID.class || type == LocalDate.class || type == LocalDateTime.class || type.isEnum()) {
|
||||||
b.append("\"");
|
b.append("\"");
|
||||||
b.append(value.toString());
|
b.append(value.toString());
|
||||||
b.append("\"");
|
b.append("\"");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package nl.sanderhautvast.json.ser;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
class LocalDateTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testLocalDate() {
|
||||||
|
assertEquals("\"2023-10-11\"", Mapper.json(LocalDate.of(2023, 10, 11)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testLocalDateTime() {
|
||||||
|
assertEquals("\"2023-10-11T13:15:27\"", Mapper.json(LocalDateTime.of(2023, 10, 11,13,15,27)));
|
||||||
|
}
|
||||||
|
}
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -5,7 +5,7 @@
|
||||||
<name>JsonToy</name>
|
<name>JsonToy</name>
|
||||||
<groupId>nl.sander</groupId>
|
<groupId>nl.sander</groupId>
|
||||||
<artifactId>jsonthingy-pom</artifactId>
|
<artifactId>jsonthingy-pom</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue