Limiting implemetation by removing the new classes.

This commit is contained in:
sk02241994
2025-10-16 14:19:19 +11:00
parent 9adea9e12d
commit c4c2beb874
5 changed files with 25 additions and 62 deletions

View File

@@ -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

View File

@@ -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);
}
}