• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JsonWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.badlogic.gdx.utils.JsonWriter的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter类的具体用法?Java JsonWriter怎么用?Java JsonWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonWriter类属于com.badlogic.gdx.utils包,在下文中一共展示了JsonWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getRequest

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
@Test
void getRequest() throws IOException {
    String expected = TestUtils.getResourceRequestString("testsResources/SearchGcOwner_request.txt",
            isDummy ? null : apiKey);

    Coordinate searchCoord = new CoordinateGPS(52.581892, 13.398128); // Home of Katipa(like Longri)
    SearchGCOwner searchGC = new SearchGCOwner(apiKey, 30, searchCoord, 50000, "bros", (byte) 2);

    StringWriter writer = new StringWriter();
    Json json = new Json(JsonWriter.OutputType.json);
    json.setWriter(writer);
    searchGC.getRequest(json);

    String actual = writer.toString();
    assertEquals(expected, actual);
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:17,代码来源:SearchGcOwnerTest.java


示例2: getRequest

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
@Test
void getRequest() throws IOException {
    String expected = TestUtils.getResourceRequestString("testsResources/GetYourUserProfile_request.txt",
            isDummy ? null : apiKey);
    GetYourUserProfile getYourUserProfile = new GetYourUserProfile(apiKey);

    StringWriter writer = new StringWriter();
    Json json = new Json(JsonWriter.OutputType.json);
    json.setWriter(writer);

    json.writeObjectStart();
    getYourUserProfile.getRequest(json);
    json.writeObjectEnd();

    String actual = writer.toString();

    //remove "DeviceOperatingSystem"
    expected = expected.replace("UNKNOWN", GetYourUserProfile.getDeviceOperatingSystem());
    assertEquals(expected, actual, "Should be equals");
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:21,代码来源:GetYourUserProfileTest.java


示例3: load

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
/**
 * Load a save file.
 * 
 * @param fileName
 *            The path to the file.
 */
public void load(FileHandle file) {
    this.clear();
    final Json json = new Json(JsonWriter.OutputType.json);

    container = json.fromJson(Container.class,
            file.readString());

    String path = file.path();
    int lastSlash = path.lastIndexOf("/");
    container.basePath =  path.substring(0, lastSlash);
    
    for (int i = 0; i < container.states.size; i++) {
        final MusicState state = container.states.get(i);
        add(state);
    }
}
 
开发者ID:ollipekka,项目名称:gdx-soundboard,代码行数:23,代码来源:MusicEventManager.java


示例4: Analytics

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
public Analytics() {
    sessionId = MathUtils.random(100000) + "-" + MathUtils.random(100000);

    if (FlippyBird.instance.preferences.contains("user_id")) {
        userId = FlippyBird.instance.preferences.getString("user_id");
    } else {
        userId = MathUtils.random(100000) + "-" + MathUtils.random(100000);
        FlippyBird.instance.preferences.putString("user_id", userId);
        FlippyBird.instance.preferences.flush();
    }

    json = new Json();
    json.setOutputType(JsonWriter.OutputType.json);

    sendUserEvent(FlippyBird.instance.platform);
}
 
开发者ID:michaelfairley,项目名称:flippy_bird,代码行数:17,代码来源:Analytics.java


示例5: flush

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
public static <T> void flush(T thing, String dir, String name) {
    try {
        final String path = dir + "/" + name;
        final File file = new File(path);
        if (!file.exists() && !file.createNewFile()) {
            throw new RuntimeException(String.format("Failed to create file '%s' because <unknown>.", path));
        }
        final PrintWriter writer = new PrintWriter(path);
        json.setOutputType(JsonWriter.OutputType.minimal);
        writer.print(json.prettyPrint(thing));
        writer.close();
    } catch (Exception e) {
        Debug.warning(e.getMessage());
        //???
    }
}
 
开发者ID:ExplatCreations,项目名称:sft,代码行数:17,代码来源:LoadUtils.java


示例6: sendToGateway

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
/**
 * Call newgrounds.io gateway
 *
 * @param component  see http://www.newgrounds.io/help/components/
 * @param parameters also see NG doc
 * @param req        callback object
 */
protected void sendToGateway(String component, JsonValue parameters, RequestResultRunnable req) {
    // if no callback is needed, provide a no-op callback
    if (req == null)
        req = new RequestResultRunnable() {
            @Override
            public void run(String json) {
            }
        };

    sendForm("{\"app_id\": \"" + ngAppId + "\",\"session_id\":\"" + sessionId + "\","
                    + "\"call\": {\"component\": \"" + component + "\",\"parameters\": " +
                    (parameters == null ? "{}" : parameters.toJson(JsonWriter.OutputType.json)) + "}}\n",
            req);
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:22,代码来源:NgioClient.java


示例7: testDefaultMapping

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
@Test
public void testDefaultMapping() {
    ControllerMappings mappings = new ControllerMappings() {
        @Override
        public boolean getDefaultMapping(MappedInputs defaultMapping) {
            defaultMapping.putMapping(new MappedInput(0, new ControllerAxis(5)));
            defaultMapping.putMapping(new MappedInput(1, new ControllerButton(2)));
            return true;
        }
    };

    ConfiguredInput axis = new ConfiguredInput(ConfiguredInput.Type.axis, 0);
    ConfiguredInput button = new ConfiguredInput(ConfiguredInput.Type.button, 1);

    mappings.addConfiguredInput(axis);
    mappings.addConfiguredInput(button);

    // ok, configuration done...
    mappings.commitConfig();

    // now check
    MockedController controller = new MockedController();


    MappedController mappedController = new MappedController(controller, mappings);
    controller.pressedButton = 2;
    assertTrue(mappedController.isButtonPressed(1));
    controller.pressedButton = 1;
    assertFalse(mappedController.isButtonPressed(1));

    TestControllerAdapter controllerAdapter = new TestControllerAdapter(mappings);
    assertTrue(controllerAdapter.buttonDown(controller, 2));
    assertEquals(1, controllerAdapter.lastEventId);
    assertTrue(controllerAdapter.axisMoved(controller, 5, .5f));
    assertEquals(0, controllerAdapter.lastEventId);

    // serialize gives only recorded mappings
    assertEquals("[]", mappings.toJson().toJson(JsonWriter.OutputType.json));
}
 
开发者ID:MrStahlfelge,项目名称:gdx-controllerutils,代码行数:40,代码来源:ControllerMappingsTest.java


示例8: dataToString

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
/**
 * Returns JSON string representation of object.
 * <p>
 * It using libgdx {@link Json} class.
 *
 * @param object Any object
 * @return JSON string representation of {@code object}
 */
public static String dataToString(Object object)
{
    if (isPrimitiveType(object))
        return object.toString();
    Json json = new Json();
    json.setTypeName(null);
    json.setQuoteLongValues(true);
    json.setIgnoreUnknownFields(true);
    json.setOutputType(JsonWriter.OutputType.json);
    return json.toJson(object);
}
 
开发者ID:mk-5,项目名称:gdx-fireapp,代码行数:20,代码来源:StringGenerator.java


示例9: mapToJSON

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
/**
 * @param map Map, not null
 * @return JSON representation of given map
 */
public static String mapToJSON(Map<String, Object> map)
{
    Json json = new Json();
    json.setTypeName(null);
    json.setQuoteLongValues(true);
    json.setIgnoreUnknownFields(true);
    json.setOutputType(JsonWriter.OutputType.json);
    return json.toJson(map, HashMap.class);
}
 
开发者ID:mk-5,项目名称:gdx-fireapp,代码行数:14,代码来源:MapTransformer.java


示例10: modify

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
/**
 * Returns modified json data.
 *
 * @param oldJsonData Old data as json string.
 * @return New data as json string
 */
public String modify(String oldJsonData)
{
    R oldData = JsonProcessor.process(wantedType, transactionCallback, oldJsonData);
    R newData = transactionCallback.run(oldData);
    Json json = new Json();
    json.setTypeName(null);
    json.setQuoteLongValues(true);
    json.setIgnoreUnknownFields(true);
    json.setOutputType(JsonWriter.OutputType.json);
    return json.toJson(newData, wantedType);
}
 
开发者ID:mk-5,项目名称:gdx-fireapp,代码行数:18,代码来源:JsonDataModifier.java


示例11: save

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
public void save(FileHandle file) {
    moveImportedFiles(saveFile, file);
    
    if (main.getProjectData().areResourcesRelative()) {
        makeResourcesRelative(file);
    }
    
    saveFile = file;
    putRecentFile(file.path());
    Json json = new Json(JsonWriter.OutputType.minimal);
    json.setUsePrototypes(false);
    file.writeString(json.prettyPrint(this), false, "UTF8");
    setChangesSaved(true);
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:15,代码来源:ProjectData.java


示例12: load

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
public void load(FileHandle file) {
    Json json = new Json(JsonWriter.OutputType.minimal);
    ProjectData instance = json.fromJson(ProjectData.class, file.reader("UTF8"));
    newProject = instance.newProject;
    jsonData.set(instance.jsonData);
    atlasData.set(instance.atlasData);
    preferences.clear();
    preferences.putAll(instance.preferences);
    
    //set main for custom classes, styles, and properties
    for (CustomClass customClass : jsonData.getCustomClasses()) {
        customClass.setMain(main);
    }
    
    saveFile = file;
    putRecentFile(file.path());
    setLastOpenSavePath(file.parent().path() + "/");
    atlasData.atlasCurrent = false;
    
    correctFilePaths();
    
    if (verifyDrawablePaths().size == 0 && verifyFontPaths().size == 0) {
        main.getRootTable().produceAtlas();
        main.getRootTable().populate();
    }
    setChangesSaved(true);
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:28,代码来源:ProjectData.java


示例13: getRequest

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
@Test
void getRequest() throws IOException {

    String expected = TestUtils.getResourceRequestString("testsResources/SearchGcCoordinate_request.txt",
            isDummy ? null : apiKey);


    //set MembershipType for tests to Premium
    GroundspeakAPI.setTestMembershipType(ApiResultState.MEMBERSHIP_TYPE_PREMIUM);

    byte apiState;
    if (GroundspeakAPI.isPremiumMember()) {
        apiState = 2;
    } else {
        apiState = 1;
    }

    SearchCoordinate searchCoordinate = new SearchCoordinate(apiKey, 50
            , LONGRI_HOME_COORDS, 50000, apiState);

    StringWriter writer = new StringWriter();
    Json json = new Json(JsonWriter.OutputType.json);
    json.setWriter(writer);
    searchCoordinate.getRequest(json);

    String actual = writer.toString();
    assertEquals(expected, actual);


}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:31,代码来源:SearchCoordinateTest.java


示例14: getRequest

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
@Test
void getRequest() throws IOException {
    String expected = TestUtils.getResourceRequestString("testsResources/SearchGc_request.txt",
            isDummy ? null : apiKey);
    SearchGC searchGC = new SearchGC(apiKey, "GC1T33T");

    StringWriter writer = new StringWriter();
    Json json = new Json(JsonWriter.OutputType.json);
    json.setWriter(writer);
    searchGC.getRequest(json);

    String actual = writer.toString();
    assertEquals(expected, actual, "Should be equals");
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:15,代码来源:SearchGCTest.java


示例15: write

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
public static void write(PlayerConfig player) {
	Json json = new Json();
	json.setOutputType(JsonWriter.OutputType.json);
	Path p = Paths.get("player/" + player.getId() + "/config.json");
	try (FileWriter fw = new FileWriter(p.toFile())) {
		fw.write(json.prettyPrint(player));
		fw.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:exch-bms2,项目名称:beatoraja,代码行数:12,代码来源:PlayerConfig.java


示例16: write

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
/**
 * コースデータを保存する
 *
 * @param cd コースデータ
 */
public void write(String name, CourseData cd) {
    try {
        Json json = new Json();
        json.setOutputType(JsonWriter.OutputType.json);
        OutputStreamWriter fw = new OutputStreamWriter(new BufferedOutputStream(
                new FileOutputStream(coursedir + "/" + name + ".json")), "UTF-8");
        fw.write(json.prettyPrint(cd));
        fw.flush();
        fw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:exch-bms2,项目名称:beatoraja,代码行数:19,代码来源:CourseDataAccessor.java


示例17: read

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
@Override
public VersionData read(Json json, JsonValue jsonData, Class type) {
    VersionData data = new VersionData();
    data.plainJson = jsonData.prettyPrint(JsonWriter.OutputType.json, 0);

    for (JsonValue entry = jsonData.child; entry != null; entry = entry.next) {
        switch (entry.name) {
            case "id":
                data.id = entry.asInt();
                break;
            case "html_url":
                data.url = entry.asString();
                break;
            case "tag_name":
                String tagName = entry.asString();
                data.tag = tagName;
                data.version = new Version(tagName);
                break;
            case "name":
                data.name = entry.asString();
                break;
            case "body":
                data.description = entry.asString();
                break;
        }
    }

    return data;
}
 
开发者ID:crashinvaders,项目名称:gdx-texture-packer-gui,代码行数:30,代码来源:VersionData.java


示例18: convert

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
public static ProjectSettings convert(ProjectSettingsDescriptor descriptor) {
    ProjectSettings settings = new ProjectSettings();
    if(descriptor == null) return settings;

    // export settings
    settings.getExport().allAssets = descriptor.isExportAllAssets();
    settings.getExport().compressScenes = descriptor.isExportCompressScenes();
    if(descriptor.getExportOutputFolder() != null && descriptor.getExportOutputFolder().length() > 0) {
        settings.getExport().outputFolder = new FileHandle(descriptor.getExportOutputFolder());
    }
    settings.getExport().jsonType = JsonWriter.OutputType.valueOf(descriptor.getJsonType());

    return settings;
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:15,代码来源:DescriptorConverter.java


示例19: generateJsonTemplate

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
private String generateJsonTemplate(String shaderName) {
  StringWriter stringWriter = new StringWriter();
  Json json = new Json(JsonWriter.OutputType.javascript);
  json.setWriter(stringWriter);
  json.writeObjectStart(); {
    json.writeValue("class", macbury.forge.shaders.Default.class.getName());
    json.writeValue("fragment", shaderName);
    json.writeValue("vertex", shaderName);
    json.writeArrayStart("structs"); {

    } json.writeArrayEnd();

    json.writeArrayStart("uniforms"); {
      json.writeValue("ProjectionMatrix");
      json.writeValue("WorldTransform");
    } json.writeArrayEnd();

    json.writeObjectStart("helpers"); {
      json.writeArrayStart("vertex"); {

      } json.writeArrayEnd();

      json.writeArrayStart("fragment"); {

      } json.writeArrayEnd();
    } json.writeObjectEnd();
  } json.writeObjectEnd();


  return stringWriter.toString();
}
 
开发者ID:macbury,项目名称:ForgE,代码行数:32,代码来源:ShadersController.java


示例20: testButtonMapping

import com.badlogic.gdx.utils.JsonWriter; //导入依赖的package包/类
@Test
public void testButtonMapping() {
    ControllerMappings mappings = new ControllerMappings();

    // We test 4 buttons
    ConfiguredInput button1 = new ConfiguredInput(ConfiguredInput.Type.button, 1);
    ConfiguredInput button2 = new ConfiguredInput(ConfiguredInput.Type.button, 2);
    ConfiguredInput button3 = new ConfiguredInput(ConfiguredInput.Type.button, 3);
    ConfiguredInput button4 = new ConfiguredInput(ConfiguredInput.Type.button, 4);

    mappings.addConfiguredInput(button1);
    mappings.addConfiguredInput(button2);
    mappings.addConfiguredInput(button3);
    mappings.addConfiguredInput(button4);

    // ok, configuration done...
    mappings.commitConfig();

    // now we connect a Controller... and map
    MockedController controller = new MockedController();
    controller.pressedButton = 107;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 1));
    //next call too fast
    assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 2));
    controller.pressedButton = 108;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 2));
    controller.pressedButton = 1;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 3));
    //TODO add assertion for check if record is complete
    assertFalse(mappings.getControllerMapping(controller).checkCompleted());
    controller.pressedButton = 4;
    assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 4));
    controller.pressedButton = -1;
    assertTrue(mappings.getControllerMapping(controller).checkCompleted());

    System.out.println(mappings.toJson().toJson(JsonWriter.OutputType.json));

    // now check
    TestControllerAdapter controllerAdapter = new TestControllerAdapter(mappings);

    assertTrue(controllerAdapter.buttonDown(controller, 108));
    assertEquals(2, controllerAdapter.lastEventId);
    assertTrue(controllerAdapter.buttonDown(controller, 4));
    assertEquals(4, controllerAdapter.lastEventId);
    assertFalse(controllerAdapter.buttonDown(controller, 2));
    assertEquals(4, controllerAdapter.lastEventId);

    MappedController mappedController = new MappedController(controller, mappings);
    controller.pressedButton = 4;
    assertTrue(mappedController.isButtonPressed(4));
    controller.pressedButton = 108;
    assertTrue(mappedController.isButtonPressed(2));
    controller.pressedButton = 99;
    assertFalse(mappedController.isButtonPressed(2));
    assertFalse(mappedController.isButtonPressed(5));

}
 
开发者ID:MrStahlfelge,项目名称:gdx-controllerutils,代码行数:58,代码来源:ControllerMappingsTest.java



注:本文中的com.badlogic.gdx.utils.JsonWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContributionItemFactory类代码示例发布时间:2022-05-21
下一篇:
Java Type类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap