本文整理了Java中com.badlogic.gdx.utils.Json.setIgnoreUnknownFields()
方法的一些代码示例,展示了Json.setIgnoreUnknownFields()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.setIgnoreUnknownFields()
方法的具体详情如下:
包路径:com.badlogic.gdx.utils.Json
类名称:Json
方法名:setIgnoreUnknownFields
[英]When true, fields in the JSON that are not found on the class will not throw a SerializationException. Default is false.
[中]如果为true,则在类中找不到的JSON字段将不会引发SerializationException。默认值为false。
代码示例来源:origin: libgdx/libgdx
private void testObjectGraph (TestMapGraph object, String typeName) {
Json json = new Json();
json.setTypeName(typeName);
json.setUsePrototypes(false);
json.setIgnoreUnknownFields(true);
json.setOutputType(OutputType.json);
String text = json.prettyPrint(object);
TestMapGraph object2 = json.fromJson(TestMapGraph.class, text);
if (object2.map.size() != object.map.size()) {
throw new RuntimeException("Too many items in deserialized json map.");
}
if (object2.objectMap.size != object.objectMap.size) {
throw new RuntimeException("Too many items in deserialized json object map.");
}
if (object2.arrayMap.size != object.arrayMap.size) {
throw new RuntimeException("Too many items in deserialized json map.");
}
}
代码示例来源:origin: DaanVanYperen/artemis-odb-contrib
private static AseFormat fromJson(FileHandle jsonFile) {
final Json json = new Json();
json.setIgnoreUnknownFields(true);
return json.fromJson(AseFormat.class, jsonFile);
}
代码示例来源:origin: net.mostlyoriginal.artemis-odb/contrib-jam
private static AseFormat fromJson(FileHandle jsonFile) {
final Json json = new Json();
json.setIgnoreUnknownFields(true);
return json.fromJson(AseFormat.class, jsonFile);
}
代码示例来源:origin: 121077313/cocostudio-ui-libgdx
jj.setIgnoreUnknownFields(true);
nodeList = jj.fromJson(List.class, ObjectData.class, json);
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
public void loadGameState(FileHandle savedFile) throws IOException {
EngineLogger.debug("LOADING GAME STATE");
if (savedFile.exists()) {
JsonValue root = new JsonReader().parse(savedFile.reader("UTF-8"));
Json json = new BladeJson(w, Mode.STATE);
json.setIgnoreUnknownFields(true);
read(json, root);
} else {
throw new IOException("LOADGAMESTATE: no saved game exists");
}
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
json.setIgnoreUnknownFields(true);
代码示例来源:origin: junkdog/artemis-odb
public JsonArtemisSerializer(World world) {
super(world);
componentCollector = new ComponentCollector(world);
referenceTracker = new ReferenceTracker(world);
lookup = new ComponentLookupSerializer();
intBagEntitySerializer = new IntBagEntitySerializer(world);
entitySerializer = new EntitySerializer(world, referenceTracker);
transmuterEntrySerializer = new TransmuterEntrySerializer();
json = new Json(JsonWriter.OutputType.json);
json.setIgnoreUnknownFields(true);
json.setSerializer(SaveFileFormat.ComponentIdentifiers.class, lookup);
json.setSerializer(Bag.class, new EntityBagSerializer(world));
json.setSerializer(IntBag.class, intBagEntitySerializer);
json.setSerializer(Entity.class, entitySerializer);
json.setSerializer(ArchetypeMapper.class, new ArchetypeMapperSerializer());
json.setSerializer(ArchetypeMapper.TransmuterEntry.class, transmuterEntrySerializer);
}
代码示例来源:origin: 121077313/cocostudio-ui-libgdx
jj.setIgnoreUnknownFields(true);
nodeList = jj.fromJson(List.class, ObjectData.class, json);
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
json.setIgnoreUnknownFields(true);
内容来源于网络,如有侵权,请联系作者删除!