当前位置: 首页>>代码示例>>Java>>正文


Java JsonWriter类代码示例

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


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


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