Examples of JsonWriter


Examples of com.adobe.epubcheck.util.JsonWriter

      if (path == null) {
          out = new PrintStream(System.out);
      } else {
          out = new FileOutputStream(path);
      }
      JsonWriter jw = JsonWriter.createJsonWriter(true);
      jw.writeJson(this, out);
    }
    finally
    {
      if (out != null)
      {
View Full Code Here

Examples of com.alibaba.druid.support.json.JSONWriter

        StatFilterContext.getInstance().executeAfter(sql, nanos, error);
        Profiler.release(nanos);
    }

    private String buildSlowParameters(StatementProxy statement) {
        JSONWriter out = new JSONWriter();

        out.writeArrayStart();
        for (int i = 0, parametersSize = statement.getParametersSize(); i < parametersSize; ++i) {
            JdbcParameter parameter = statement.getParameter(i);
            if (i != 0) {
                out.writeComma();
            }
            if (parameter == null) {
                continue;
            }

            Object value = parameter.getValue();
            if (value == null) {
                out.writeNull();
            } else if (value instanceof String) {
                String text = (String) value;
                if (text.length() > 100) {
                    out.writeString(text.substring(0, 97) + "...");
                } else {
                    out.writeString(text);
                }
            } else if (value instanceof Number) {
                out.writeObject(value);
            } else if (value instanceof java.util.Date) {
                out.writeObject(value);
            } else if (value instanceof Boolean) {
                out.writeObject(value);
            } else if (value instanceof InputStream) {
                out.writeString("<InputStream>");
            } else if (value instanceof NClob) {
                out.writeString("<NClob>");
            } else if (value instanceof Clob) {
                out.writeString("<Clob>");
            } else if (value instanceof Blob) {
                out.writeString("<Blob>");
            } else {
                out.writeString('<' + value.getClass().getName() + '>');
            }
        }
        out.writeArrayEnd();

        return out.toString();
    }
View Full Code Here

Examples of com.alibaba.fastjson.JSONWriter

public class JSONWriterTest extends TestCase {

    public void test_0() throws Exception {
        StringWriter out = new StringWriter();

        JSONWriter writer = new JSONWriter(out);
        writer.writeStartObject();
        writer.writeEndObject();
        writer.flush();

        Assert.assertEquals("{}", out.toString());
    }
View Full Code Here

Examples of com.amazonaws.util.json.JSONWriter

            throw new IllegalArgumentException("Policy cannot be null");
        }

        StringWriter writer = new StringWriter();
        try {
            JSONWriter generator = new JSONWriter(writer);
            writePolicy(policy, generator);
            return writer.toString();
        } catch (Exception e) {
            String message = "Unable to serialize policy to JSON string: " + e.getMessage();
            throw new IllegalArgumentException(message, e);
View Full Code Here

Examples of com.cedarsoftware.util.io.JsonWriter

                c.setRequestMethod("POST");
                setCookies(c);

                // Formulate the JSON call as a String
                ByteArrayOutputStream ba_out = new ByteArrayOutputStream();
                JsonWriter jwr = new JsonWriter(ba_out);
                jwr.write(new Object[] {m.getName(), args});
                IOUtilities.close(jwr);

                if (LOG.isDebugEnabled())
                {    // DEBUG
                    String jsonCall = new String(ba_out.toByteArray(), "UTF-8");
View Full Code Here

Examples of com.esri.gpt.server.usage.common.JSONWriter

    String outputFormat = Val.chkStr(attrMap.getValue("f"));
    if (outputFormat.equalsIgnoreCase("json")
        && statReqContext.getRequestType().equalsIgnoreCase(
            StatisticsTypes.HARVESTER.toString())) {
      response.setContentType("text/plain; charset=UTF-8");
      rsWriter = new JSONWriter(writer,
          statReqContext.getResponseString());
    } else if (outputFormat.equalsIgnoreCase("html")) {
      throw new Exception("Output format not supported.");
    } else if (outputFormat.equalsIgnoreCase("xml")) {
      throw new Exception("Output format not supported.");
    } else {
      rsWriter = new JSONWriter(writer,
          statReqContext.getResponseString());
    }
    statReqContext.setWriter(rsWriter);
  }
View Full Code Here

Examples of com.github.nmorel.gwtjackson.client.stream.JsonWriter

        return write( value, new JsonSerializationContext.Builder().build() );
    }

    @Override
    public String write( T value, JsonSerializationContext ctx ) throws JsonSerializationException {
        JsonWriter writer = ctx.newJsonWriter();
        try {
            if ( ctx.isWrapRootValue() ) {
                writer.beginObject();
                writer.name( rootName );
                getSerializer().serialize( writer, value, ctx );
                writer.endObject();
            } else {
                getSerializer().serialize( writer, value, ctx );
            }
            return writer.getOutput();
        } catch ( JsonSerializationException e ) {
            // already logged, we just throw it
            throw e;
        } catch ( RuntimeException e ) {
            throw ctx.traceError( value, e, writer );
View Full Code Here

Examples of com.google.appengine.repackaged.org.json.JSONWriter

    // Get current activity
    Student student = AuthController.getCurrentStudent();
    Activity activity = StudentController.getCurrentActivity(student);
   
    // Output as JSON
    JSONWriter writer = new JSONWriter(resp.getWriter());
    try {
      writer.object().key("activity");
      if(activity != null) {
        writer.value(activity.toJSON());
      } else {
        writer.value(null);
      }
      writer.endObject();
    } catch(JSONException e) {
      resp.getWriter().println("{\"activity\":null}");
    }
  }
View Full Code Here

Examples of com.google.gson.stream.JsonWriter

  public void toJson(JsonElement jsonElement, Appendable writer) throws JsonIOException {
    try {
      if (generateNonExecutableJson) {
        writer.append(JSON_NON_EXECUTABLE_PREFIX);
      }
      JsonWriter jsonWriter = new JsonWriter(Streams.writerForAppendable(writer));
      if (prettyPrinting) {
        jsonWriter.setIndent("  ");
      }
      toJson(jsonElement, jsonWriter);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
View Full Code Here

Examples of com.ibm.commons.util.io.json.util.JsonWriter

    }
  }
 
  public String generateAsStringHier(TreeModel tree, ViewNavigator nav, boolean compact) throws NotesException, IOException {
    StringWriter sw = new StringWriter();
    JsonWriter jw = new JsonWriter(sw, compact);
    generateHier(tree, nav, jw);
    jw.flush();
    return sw.toString();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.