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

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

本文整理了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

json.setUsePrototypes(false);
json.setSerializer(Skin.class, new ReadOnlySerializer<Skin>() {
  public Skin read (Json json, JsonValue typeToValueMap, Class ignored) {
    for (JsonValue valueMap = typeToValueMap.child; valueMap != null; valueMap = valueMap.next) {
json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
  public BitmapFont read (Json json, JsonValue jsonData, Class type) {
    String path = json.readValue("file", String.class, jsonData);
json.setSerializer(Color.class, new ReadOnlySerializer<Color>() {
  public Color read (Json json, JsonValue jsonData, Class type) {
    if (jsonData.isString()) return get(jsonData.asString(), Color.class);
json.setSerializer(TintedDrawable.class, new ReadOnlySerializer() {
  public Object read (Json json, JsonValue jsonData, Class type) {
    String name = json.readValue("name", String.class, jsonData);

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

json.setUsePrototypes(false);
json.setSerializer(Skin.class, new ReadOnlySerializer<Skin>() {
  public Skin read (Json json, JsonValue typeToValueMap, Class ignored) {
    for (JsonValue valueMap = typeToValueMap.child; valueMap != null; valueMap = valueMap.next) {
json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
  public BitmapFont read (Json json, JsonValue jsonData, Class type) {
    String path = json.readValue("file", String.class, jsonData);
json.setSerializer(Color.class, new ReadOnlySerializer<Color>() {
  public Color read (Json json, JsonValue jsonData, Class type) {
    if (jsonData.isString()) return get(jsonData.asString(), Color.class);
json.setSerializer(TintedDrawable.class, new ReadOnlySerializer() {
  public Object read (Json json, JsonValue jsonData, Class type) {
    String name = json.readValue("name", String.class, jsonData);

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

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

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

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

代码示例来源: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: bladecoder/bladecoder-adventure-engine

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

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

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

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

json.setUsePrototypes(false);
json.setSerializer(Skin.class, new ReadOnlySerializer<Skin>() {
  public Skin read (Json json, JsonValue typeToValueMap, Class ignored) {
    for (JsonValue valueMap = typeToValueMap.child; valueMap != null; valueMap = valueMap.next) {
json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
  public BitmapFont read (Json json, JsonValue jsonData, Class type) {
    String path = json.readValue("file", String.class, jsonData);
json.setSerializer(Color.class, new ReadOnlySerializer<Color>() {
  public Color read (Json json, JsonValue jsonData, Class type) {
    if (jsonData.isString()) return get(jsonData.asString(), Color.class);
json.setSerializer(TintedDrawable.class, new ReadOnlySerializer() {
  public Object read (Json json, JsonValue jsonData, Class type) {
    String name = json.readValue("name", String.class, jsonData);

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

json.setSerializer(Pattern.class, new Serializer<Pattern>() {
  @Override
  public void write(Json json, Pattern object, Class knownType) {
json.setSerializer(Coord.class, new Serializer<Coord>() {
  @Override
  public void write(Json json, Coord object, Class knownType) {
json.setSerializer(GreasedRegion.class, new Serializer<GreasedRegion>() {
  @Override
  public void write(Json json, GreasedRegion object, Class knownType) {
json.setSerializer(IntVLA.class, new Serializer<IntVLA>() {
  @Override
  public void write(Json json, IntVLA object, Class knownType) {
json.setSerializer(IntDoubleOrderedMap.class, new Serializer<IntDoubleOrderedMap>() {
  @Override
  public void write(Json json, IntDoubleOrderedMap object, Class knownType) {
json.setSerializer(StringStringMap.class, new Serializer<StringStringMap>() {
  @Override
  public void write(Json json, StringStringMap object, Class knownType) {
json.setSerializer(OrderedMap.class, new Serializer<OrderedMap>() {
  @Override
  public void write(Json json, OrderedMap object, Class knownType) {
json.setSerializer(EnumOrderedMap.class, new Serializer<EnumOrderedMap>() {

相关文章