本文整理了Java中org.boon.json.ObjectMapper.fromJson()
方法的一些代码示例,展示了ObjectMapper.fromJson()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectMapper.fromJson()
方法的具体详情如下:
包路径:org.boon.json.ObjectMapper
类名称:ObjectMapper
方法名:fromJson
暂无
代码示例来源:origin: boonproject/boon
/**
* Parse a text representation of a JSON data structure
*
* @param text JSON text to parse
* @return a data structure of lists and maps
*/
public Object parseText(String text) {
if (text == null || text.length() == 0) {
throw new IllegalArgumentException("The JSON input text should neither be null nor empty.");
}
return JsonFactory.create().fromJson ( text );
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_normal() {
String json = "{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_stringArrayProperty_fromSingleValue() {
String json = "{\"typeName\":\"Processes\",\"descriptions\":\"lala\"}";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"descriptions\":[\"lala\"]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_uppercase() {
String json = "{\"TYPENAME\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_normal() {
String json = "{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_stringArrayProperty() {
String json = "{\"typeName\":\"Processes\",\"descriptions\":[\"lala\"]}";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"descriptions\":[\"lala\"]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_stringListProperty() {
String json = "{\"typeName\":\"Processes\",\"descriptions2\":[\"lala\"]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"descriptions2\":[\"lala\"]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_uppercase() {
String json = "{\"TYPENAME\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_lowercase() {
String json = "{\"typename\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_normal() {
String json = "{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_uppercase() {
String json = "{\"TYPENAME\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_arrayProperty() {
String json = "{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_lowercase() {
String json = "{\"typename\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_arrayProperty_fromSingleValue() {
String json = "{\"typeName\":\"Processes\",\"fields\":{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_listProperty_fromSingleValue() {
String json = "{\"typeName\":\"Processes\",\"fields2\":{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields2\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_stringListProperty_fromSingleValue() {
String json = "{\"typeName\":\"Processes\",\"descriptions2\":\"lala\"} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"descriptions2\":[\"lala\"]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_lowercase() {
String json = "{\"typename\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test_caseInsensitiveProperty_normal() {
String json = "{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]} ";
ApiDynamicType map = objectMapper.fromJson(json, ApiDynamicType.class);
puts(json);
puts(objectMapper.toJson(map));
assertThat(objectMapper.fromJson(objectMapper.toJson(map)), is(objectMapper.fromJson("{\"typeName\":\"Processes\",\"fields\":[{\"name\":\"process\",\"type\":\"ConversionRateProcess[]\",\"properties\":[\"REQUIRED\"]}]}")));
}
代码示例来源:origin: boonproject/boon
@Test
public void test2() {
user = new User("red", "yellow", "green", "purple");
puts(user.getFavoriteColors());
final ObjectMapper objectMapper = JsonFactory.createUseAnnotations(true);
json = objectMapper.toJson(user);
puts(json);
user2 = objectMapper.fromJson(json, User.class);
puts(user.getFavoriteColors());
ok = user.equals(user2) || die("Users should be equal", user, user2);
}
代码示例来源:origin: boonproject/boon
public void test3() {
user = new User("red", "yellow", "green", "purple");
puts(user.getFavoriteColors());
final JsonParserFactory jsonParserFactory = new JsonParserFactory().usePropertiesFirst().useAnnotations();
final JsonSerializerFactory serializerFactory = new JsonSerializerFactory().includeNulls().useAnnotations();
final ObjectMapper objectMapper = new ObjectMapperImpl(jsonParserFactory, serializerFactory);
json = objectMapper.toJson(user);
puts(json);
user2 = objectMapper.fromJson(json, User.class);
puts(user.getFavoriteColors());
ok = user.equals(user2) || die("Users should be equal", user, user2);
}
内容来源于网络,如有侵权,请联系作者删除!