com.badlogic.gdx.utils.Json.setSerializer()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中com.badlogic.gdx.utils.Json.setSerializer()方法的一些代码示例,展示了Json.setSerializer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.setSerializer()方法的具体详情如下:
包路径:com.badlogic.gdx.utils.Json
类名称:Json
方法名:setSerializer

Json.setSerializer介绍

[英]Registers a serializer to use for the specified type instead of the default behavior of serializing all of an objects fields.
[中]注册用于指定类型的序列化程序,而不是序列化所有对象字段的默认行为。

代码示例

代码示例来源:origin: libgdx/libgdx

  1. json.setUsePrototypes(false);
  2. json.setSerializer(Skin.class, new ReadOnlySerializer<Skin>() {
  3. public Skin read (Json json, JsonValue typeToValueMap, Class ignored) {
  4. for (JsonValue valueMap = typeToValueMap.child; valueMap != null; valueMap = valueMap.next) {
  5. json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
  6. public BitmapFont read (Json json, JsonValue jsonData, Class type) {
  7. String path = json.readValue("file", String.class, jsonData);
  8. json.setSerializer(Color.class, new ReadOnlySerializer<Color>() {
  9. public Color read (Json json, JsonValue jsonData, Class type) {
  10. if (jsonData.isString()) return get(jsonData.asString(), Color.class);
  11. json.setSerializer(TintedDrawable.class, new ReadOnlySerializer() {
  12. public Object read (Json json, JsonValue jsonData, Class type) {
  13. String name = json.readValue("name", String.class, jsonData);

代码示例来源:origin: libgdx/libgdx

  1. json.setUsePrototypes(false);
  2. json.setSerializer(Skin.class, new ReadOnlySerializer<Skin>() {
  3. public Skin read (Json json, JsonValue typeToValueMap, Class ignored) {
  4. for (JsonValue valueMap = typeToValueMap.child; valueMap != null; valueMap = valueMap.next) {
  5. json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
  6. public BitmapFont read (Json json, JsonValue jsonData, Class type) {
  7. String path = json.readValue("file", String.class, jsonData);
  8. json.setSerializer(Color.class, new ReadOnlySerializer<Color>() {
  9. public Color read (Json json, JsonValue jsonData, Class type) {
  10. if (jsonData.isString()) return get(jsonData.asString(), Color.class);
  11. json.setSerializer(TintedDrawable.class, new ReadOnlySerializer() {
  12. public Object read (Json json, JsonValue jsonData, Class type) {
  13. String name = json.readValue("name", String.class, jsonData);

代码示例来源:origin: junkdog/artemis-odb

  1. @Override
  2. public WorldSerializationManager.ArtemisSerializer register(Class<?> type, Json.Serializer serializer) {
  3. json.setSerializer(type, serializer);
  4. return this;
  5. }

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

  1. @Initiate void initialize() {
  2. json = new Json();
  3. json.setSerializer(ScaleFactorModel.class, new ScaleFactorJsonSerializer());
  4. json.setSerializer(InputFile.class, inputFileSerializer = new InputFileSerializer());
  5. }

代码示例来源:origin: junkdog/artemis-odb

  1. public JsonArtemisSerializer(World world) {
  2. super(world);
  3. componentCollector = new ComponentCollector(world);
  4. referenceTracker = new ReferenceTracker(world);
  5. lookup = new ComponentLookupSerializer();
  6. intBagEntitySerializer = new IntBagEntitySerializer(world);
  7. entitySerializer = new EntitySerializer(world, referenceTracker);
  8. transmuterEntrySerializer = new TransmuterEntrySerializer();
  9. json = new Json(JsonWriter.OutputType.json);
  10. json.setIgnoreUnknownFields(true);
  11. json.setSerializer(SaveFileFormat.ComponentIdentifiers.class, lookup);
  12. json.setSerializer(Bag.class, new EntityBagSerializer(world));
  13. json.setSerializer(IntBag.class, intBagEntitySerializer);
  14. json.setSerializer(Entity.class, entitySerializer);
  15. json.setSerializer(ArchetypeMapper.class, new ArchetypeMapperSerializer());
  16. json.setSerializer(ArchetypeMapper.TransmuterEntry.class, transmuterEntrySerializer);
  17. }

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

  1. json.setSerializer(Skin.class, new ReadOnlySerializer<Skin>() {
  2. @Override
  3. public Skin read(Json json, JsonValue typeToValueMap, @SuppressWarnings("rawtypes") Class ignored) {
  4. json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
  5. @Override
  6. public BitmapFont read(Json json, JsonValue jsonData, @SuppressWarnings("rawtypes") Class type) {

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

  1. @Initiate
  2. public void initialize() {
  3. json = new Json();
  4. json.setSerializer(VersionData.class, new VersionData.Serializer());
  5. }

代码示例来源:origin: com.badlogicgames.gdx/gdx

  1. json.setUsePrototypes(false);
  2. json.setSerializer(Skin.class, new ReadOnlySerializer<Skin>() {
  3. public Skin read (Json json, JsonValue typeToValueMap, Class ignored) {
  4. for (JsonValue valueMap = typeToValueMap.child; valueMap != null; valueMap = valueMap.next) {
  5. json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
  6. public BitmapFont read (Json json, JsonValue jsonData, Class type) {
  7. String path = json.readValue("file", String.class, jsonData);
  8. json.setSerializer(Color.class, new ReadOnlySerializer<Color>() {
  9. public Color read (Json json, JsonValue jsonData, Class type) {
  10. if (jsonData.isString()) return get(jsonData.asString(), Color.class);
  11. json.setSerializer(TintedDrawable.class, new ReadOnlySerializer() {
  12. public Object read (Json json, JsonValue jsonData, Class type) {
  13. String name = json.readValue("name", String.class, jsonData);

代码示例来源:origin: SquidPony/SquidLib

  1. json.setSerializer(Pattern.class, new Serializer<Pattern>() {
  2. @Override
  3. public void write(Json json, Pattern object, Class knownType) {
  4. json.setSerializer(Coord.class, new Serializer<Coord>() {
  5. @Override
  6. public void write(Json json, Coord object, Class knownType) {
  7. json.setSerializer(GreasedRegion.class, new Serializer<GreasedRegion>() {
  8. @Override
  9. public void write(Json json, GreasedRegion object, Class knownType) {
  10. json.setSerializer(IntVLA.class, new Serializer<IntVLA>() {
  11. @Override
  12. public void write(Json json, IntVLA object, Class knownType) {
  13. json.setSerializer(IntDoubleOrderedMap.class, new Serializer<IntDoubleOrderedMap>() {
  14. @Override
  15. public void write(Json json, IntDoubleOrderedMap object, Class knownType) {
  16. json.setSerializer(StringStringMap.class, new Serializer<StringStringMap>() {
  17. @Override
  18. public void write(Json json, StringStringMap object, Class knownType) {
  19. json.setSerializer(OrderedMap.class, new Serializer<OrderedMap>() {
  20. @Override
  21. public void write(Json json, OrderedMap object, Class knownType) {
  22. json.setSerializer(EnumOrderedMap.class, new Serializer<EnumOrderedMap>() {

相关文章