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

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

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

Json.prettyPrint介绍

暂无

代码示例

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

public String prettyPrint (Object object) {
  return prettyPrint(object, 0);
}

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

public String prettyPrint (Object object) {
  return prettyPrint(object, 0);
}

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

public String prettyPrint (String json) {
  return prettyPrint(json, 0);
}

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

public String prettyPrint (String json) {
  return prettyPrint(json, 0);
}

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

public String prettyPrint (Object object, int singleLineColumns) {
  return prettyPrint(toJson(object), singleLineColumns);
}

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

public String prettyPrint (Object object, PrettyPrintSettings settings) {
  return prettyPrint(toJson(object), settings);
}

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

public String prettyPrint (Object object, PrettyPrintSettings settings) {
  return prettyPrint(toJson(object), settings);
}

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

public String prettyPrint (Object object, int singleLineColumns) {
  return prettyPrint(toJson(object), singleLineColumns);
}

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

private String roundTrip (Object object) {
  String text = json.toJson(object);
  System.out.println(text);
  test(text, object);
  text = json.prettyPrint(object, 130);
  test(text, object);
  return text;
}

代码示例来源: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: com.badlogicgames.gdx/gdx

public String prettyPrint (String json) {
  return prettyPrint(json, 0);
}

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

public String prettyPrint (Object object) {
  return prettyPrint(object, 0);
}

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

public String prettyPrint (Object object, int singleLineColumns) {
  return prettyPrint(toJson(object), singleLineColumns);
}

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

public String prettyPrint (Object object, PrettyPrintSettings settings) {
  return prettyPrint(toJson(object), settings);
}

代码示例来源:origin: TomGrill/gdx-firebase

public String prettyPrint() {
    return json.prettyPrint(build());
  }
}

代码示例来源:origin: dsaltares/libgdx-cookbook

@Override
  public void create() {
    
    System.out.println("======================");
    System.out.println("Reading character.json");
    System.out.println("======================");
    
    Json json = new Json();
    json.setElementType(Character.class, "items", Item.class);
    Character character = json.fromJson(Character.class, Gdx.files.internal("data/character.json"));
    System.out.println(character);
    
    System.out.println();
    
    System.out.println("=====================");
    System.out.println("Serializing character");
    System.out.println("=====================");
    
    System.out.println(json.prettyPrint(json.toJson(character)));
    
    Gdx.app.exit();
  }
}

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

public void save() {

    Json json = new Json();

    // String s = json.prettyPrint(list);
    String s = json.toJson(list, ArrayList.class, TimeVerb.class);
    s = json.prettyPrint(s);

    Writer w = EngineAssetManager.getInstance().getUserFile(fileName + RECORD_EXT).writer(false, "UTF-8");

    try {
      w.write(s);
      w.close();
    } catch (IOException e) {
      EngineLogger.error("ERROR SAVING RECORD", e);
    }
  }
}

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

public void saveModel(String chapterId) throws IOException {
  EngineLogger.debug("SAVING GAME MODEL");
  if (w.isDisposed())
    return;
  Json json = new BladeJson(w, Mode.MODEL);
  json.setOutputType(OutputType.javascript);
  String s = null;
  if (EngineLogger.debugMode())
    s = json.prettyPrint(this);
  else
    s = json.toJson(this);
  Writer w = EngineAssetManager.getInstance().getModelFile(chapterId + EngineAssetManager.CHAPTER_EXT)
      .writer(false, "UTF-8");
  try {
    w.write(s);
    w.flush();
  } catch (IOException e) {
    throw new IOException("ERROR SAVING MODEL", e);
  } finally {
    w.close();
  }
}

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

public void save(Writer writer, SaveFileFormat save) {
  try {
    referenceTracker.inspectTypes(world);
    referenceTracker.preWrite(save);
    save.archetypes = new ArchetypeMapper(world, save.entities);
    componentCollector.preWrite(save);
    entitySerializer.serializationState = save;
    transmuterEntrySerializer.identifiers = save.componentIdentifiers;
    entitySerializer.archetypeMapper = new ArchetypeMapper(world, save.entities);
    entitySerializer.archetypeMapper.serializationState = save;
    save.componentIdentifiers.build();
    if (prettyPrint) {
      writer.append(json.prettyPrint(save));
      writer.flush();
    } else {
      json.toJson(save, writer);
    }
  } catch (IOException e) {
    throw new SerializationException(e);
  }
}

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

public void saveWorldDesc(FileHandle file) throws IOException {
  float scale = EngineAssetManager.getInstance().getScale();
  Json json = new BladeJson(w, Mode.MODEL);
  json.setOutputType(OutputType.javascript);
  json.setWriter(new StringWriter());
  json.writeObjectStart();
  json.writeValue("width", w.getWidth() / scale);
  json.writeValue("height", w.getHeight() / scale);
  json.writeValue("initChapter", w.getInitChapter());
  w.getVerbManager().write(json);
  json.writeObjectEnd();
  String s = null;
  if (EngineLogger.debugMode())
    s = json.prettyPrint(json.getWriter().getWriter().toString());
  else
    s = json.getWriter().getWriter().toString();
  Writer w = file.writer(false, "UTF-8");
  w.write(s);
  w.close();
}

相关文章