Example usage for com.fasterxml.jackson.jr.ob JSON write

List of usage examples for com.fasterxml.jackson.jr.ob JSON write

Introduction

In this page you can find the example usage for com.fasterxml.jackson.jr.ob JSON write.

Prototype

public void write(Object value, File f) throws IOException, JSONObjectException 

Source Link

Usage

From source file:io.fineo.drill.rule.TestDrill.java

@Test
public void testReadWrite() throws Exception {
    // writer a simple json file
    Map<String, Object> json = new HashMap<>();
    json.put("a", "c");

    File tmp = folder.newFolder("drill");
    File out = new File(tmp, "test.json");
    JSON j = JSON.std;
    j.write(json, out);

    try (Connection conn = drill.getConnection()) {
        conn.createStatement().execute("ALTER SESSION SET `store.format`='json'");
        String select = String.format("SELECT * FROM dfs.`%s`", out.getPath());
        ResultSet results = conn.createStatement().executeQuery(select);
        assertTrue(results.next());//from  w  w w .  j  ava  2 s  .  c o m
        assertEquals(json.get("a"), results.getString("a"));
        assertEquals(1, results.getMetaData().getColumnCount());
    }
}