优化ConvertFactory.features
This commit is contained in:
@@ -5,11 +5,10 @@
|
||||
*/
|
||||
package org.redkale.test.convert;
|
||||
|
||||
import org.redkale.util.TypeToken;
|
||||
import org.redkale.convert.json.JsonFactory;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.util.TypeToken;
|
||||
|
||||
/**
|
||||
* 支持泛型的
|
||||
@@ -36,7 +35,7 @@ public class GenericEntity<T, K, V> {
|
||||
bean.setEntry(new Entry<>("aaaa", SimpleEntity.create()));
|
||||
final Type type = new TypeToken<GenericEntity<Long, String, SimpleEntity>>() {
|
||||
}.getType();
|
||||
JsonFactory.root().tiny(true);
|
||||
JsonFactory.root().withTinyFeature(true);
|
||||
String json = JsonConvert.root().convertTo(bean);
|
||||
System.out.println(json);
|
||||
System.out.println(JsonConvert.root().convertFrom(type, json).toString());
|
||||
|
||||
@@ -4,7 +4,7 @@ package org.redkale.test.convert;
|
||||
|
||||
import java.util.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.redkale.convert.ConvertFactory;
|
||||
import org.redkale.convert.Convert;
|
||||
import org.redkale.convert.json.*;
|
||||
|
||||
/**
|
||||
@@ -24,7 +24,7 @@ public class Json5Test {
|
||||
|
||||
@Test
|
||||
public void run1() throws Exception {
|
||||
JsonFactory factory = JsonFactory.root().features(ConvertFactory.FEATURE_TINY | ConvertFactory.FEATURE_NULLABLE);
|
||||
JsonFactory factory = JsonFactory.root().withFeatures(Convert.FEATURE_TINY | Convert.FEATURE_NULLABLE);
|
||||
final JsonConvert convert = factory.getConvert();
|
||||
Json5Bean bean = new Json5Bean();
|
||||
bean.id = 60;
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.redkale.convert.ConvertFactory;
|
||||
import org.redkale.convert.Convert;
|
||||
import org.redkale.convert.json.*;
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ public class JsonMainTest {
|
||||
|
||||
@Test
|
||||
public void run1() throws Throwable {
|
||||
JsonFactory factory = JsonFactory.root().features(ConvertFactory.FEATURE_TINY);
|
||||
JsonFactory factory = JsonFactory.root().withFeatures(Convert.FEATURE_TINY);
|
||||
final JsonConvert convert = JsonConvert.root();
|
||||
String json = "{\"access_token\":\"null\",\"priv\":null, vvv:nulla,\"priv2\":\"nulla\",\"expires_in\":7200, \"aa\":\"\"}";
|
||||
Map<String, String> map = convert.convertFrom(JsonConvert.TYPE_MAP_STRING_STRING, json);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package org.redkale.test.convert;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.redkale.convert.ConvertFactory;
|
||||
import org.redkale.convert.Convert;
|
||||
import org.redkale.convert.json.*;
|
||||
|
||||
/**
|
||||
@@ -25,7 +25,7 @@ public class TinyTest {
|
||||
TinyRecord record = new TinyRecord();
|
||||
record.id = 5;
|
||||
{
|
||||
JsonFactory factory = JsonFactory.create().features(ConvertFactory.FEATURE_TINY);
|
||||
JsonFactory factory = JsonFactory.create().withFeatures(Convert.FEATURE_TINY);
|
||||
JsonConvert convert = factory.getConvert();
|
||||
String json = "{\"id\":5}";
|
||||
if (!main) {
|
||||
@@ -34,7 +34,7 @@ public class TinyTest {
|
||||
System.out.println(convert.convertTo(record));
|
||||
}
|
||||
{
|
||||
JsonFactory factory = JsonFactory.create().features(0);
|
||||
JsonFactory factory = JsonFactory.create().withFeatures(0);
|
||||
JsonConvert convert = factory.getConvert();
|
||||
String json = "{\"id\":5,\"name\":\"\"}";
|
||||
if (!main) {
|
||||
|
||||
Reference in New Issue
Block a user