mirror of
https://github.com/stleary/JSON-java.git
synced 2026-03-20 00:00:50 -04:00
Limiting implemetation by removing the new classes.
This commit is contained in:
@@ -36,7 +36,6 @@ import org.json.JSONString;
|
||||
import org.json.JSONTokener;
|
||||
import org.json.ParserConfiguration;
|
||||
import org.json.XML;
|
||||
import org.json.TypeConverter;
|
||||
import org.json.junit.data.BrokenToString;
|
||||
import org.json.junit.data.ExceptionalBean;
|
||||
import org.json.junit.data.Fraction;
|
||||
@@ -4121,17 +4120,13 @@ public class JSONObjectTest {
|
||||
|
||||
@Test
|
||||
public void jsonObjectParseFromJson_1() {
|
||||
JSONObject object = new JSONObject();
|
||||
object.setClassMapping(java.time.LocalDateTime.class, new TypeConverter<java.time.LocalDateTime>() {
|
||||
public java.time.LocalDateTime convert(Object input) {
|
||||
return java.time.LocalDateTime.parse((String) input);
|
||||
}
|
||||
});
|
||||
java.time.LocalDateTime localDateTime = java.time.LocalDateTime.now();
|
||||
object.put("localDate", localDateTime.toString());
|
||||
CustomClassA customClassA = object.fromJson(CustomClassA.class);
|
||||
CustomClassA compareClassClassA = new CustomClassA(localDateTime);
|
||||
assertEquals(customClassA, compareClassClassA);
|
||||
JSONObject object = new JSONObject();
|
||||
|
||||
BigInteger largeInt = new BigInteger("123");
|
||||
object.put("largeInt", largeInt.toString());
|
||||
CustomClassA customClassA = object.fromJson(CustomClassA.class);
|
||||
CustomClassA compareClassClassA = new CustomClassA(largeInt);
|
||||
assertEquals(customClassA, compareClassClassA);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package org.json.junit.data;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class CustomClassA {
|
||||
public java.time.LocalDateTime localDate;
|
||||
public BigInteger largeInt;
|
||||
|
||||
public CustomClassA() {}
|
||||
public CustomClassA(java.time.LocalDateTime localDate) {
|
||||
this.localDate = localDate;
|
||||
public CustomClassA(BigInteger largeInt) {
|
||||
this.largeInt = largeInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
CustomClassA classA = (CustomClassA) o;
|
||||
return this.localDate.equals(classA.localDate);
|
||||
return this.largeInt.equals(classA.largeInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user