Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonFactory


      DatumReader<Object> reader = new GenericDatumReader<Object>(schema);
      binDecoder.set(DecoderFactory.defaultFactory().createBinaryDecoder(valueBytes, binDecoder.get()));

      Object datum = reader.read(null, binDecoder.get());
      DatumWriter<Object> writer = new GenericDatumWriter<Object>(schema);
      JsonGenerator g = new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8);
      // write the src ID
      g.writeStartObject();
      g.writeFieldName(SRC_ID_FIELD_NAME);
      g.writeNumber(e.getSourceId());
      g.writeFieldName(OPCODE_FIELD_NAME);
View Full Code Here


    return result;
  }

  public void convert(InputStream in, OutputStream out) throws IOException
  {
    JsonGenerator jsonGenerator = (new JsonFactory()).createJsonGenerator(new OutputStreamWriter(out));
    if (AvroFormat.JSON == _outputFormat) jsonGenerator.useDefaultPrettyPrinter();

    List<GenericRecord> result = convert(in);
    Encoder outputEncoder = (AvroFormat.BINARY == _outputFormat) ?
        new BinaryEncoder(out) :
View Full Code Here

    }
    case JSON_PLAIN_VALUE:
    case JSON:
    {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JsonFactory f = new JsonFactory();
      try {
        JsonGenerator g = f.createJsonGenerator(baos, JsonEncoding.UTF8);
        g.writeStartObject();
        int version = getVersion();
        if (version == DbusEventFactory.DBUS_EVENT_V1)
        {
          writeJSON_V1(g,encoding);
View Full Code Here

            log.log(Level.SEVERE, e.getMessage());
        }

        final LoginInfo loginInfo = new LoginInfo();
        try {
            final JsonFactory f = new JsonFactory();
            JsonParser jp;
            jp = f.createJsonParser(r.toString());
            jp.nextToken();
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                final String fieldname = jp.getCurrentName();
                jp.nextToken();
                if ("picture".equals(fieldname)) {
View Full Code Here

   * @param out the Writer to write to
   * @throws IOException
   */
  public static void dumpConfiguration(Configuration config,
      Writer out) throws IOException {
    JsonFactory dumpFactory = new JsonFactory();
    JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
    dumpGenerator.writeStartObject();
    dumpGenerator.writeFieldName("properties");
    dumpGenerator.writeStartArray();
    dumpGenerator.flush();
    synchronized (config) {
View Full Code Here

      if (keys == null) {
        keys = new HashSet<String>();
        discoveredI18nMap.put(locale, keys);
      }
      is = TranslationServiceGenerator.class.getClassLoader().getResourceAsStream(bundlePath);
      JsonFactory jsonFactory = new JsonFactory();
      JsonParser jp = jsonFactory.createJsonParser(is);
      JsonToken token = jp.nextToken();
      while (token != null) {
        token = jp.nextToken();
        if (token == JsonToken.FIELD_NAME) {
          String name = jp.getCurrentName();
View Full Code Here

  private static void outputBundleFile(Map<String, String> i18nValues, File bundleFile, Set<String> onlyTheseKeys) {
    if (onlyTheseKeys != null && onlyTheseKeys.isEmpty())
      return;

    try {
      JsonFactory f = new JsonFactory();
      JsonGenerator g = f.createJsonGenerator(bundleFile, JsonEncoding.UTF8);
      g.useDefaultPrettyPrinter();
      g.writeStartObject();
      Set<String> orderedKeys = new TreeSet<String>(i18nValues.keySet());
      for (String key : orderedKeys) {
        String value = i18nValues.get(key);
View Full Code Here

    {
        File manifestFile = cfs.directories.getOrCreateLeveledManifest();
        File oldFile = new File(manifestFile.getPath().replace(EXTENSION, "-old.json"));
        File tmpFile = new File(manifestFile.getPath().replace(EXTENSION, "-tmp.json"));

        JsonFactory f = new JsonFactory();
        try
        {
            FileOutputStream fos = new FileOutputStream(tmpFile);
            JsonGenerator g = f.createJsonGenerator(fos, JsonEncoding.UTF8);
            g.useDefaultPrettyPrinter();
            g.writeStartObject();
            g.writeArrayFieldStart("generations");
            for (int level = 0; level < generations.length; level++)
            {
View Full Code Here

  private final JsonNode data;
 
  public TestResolvingGrammarGenerator(String jsonSchema, String jsonData)
    throws IOException {
    this.schema = Schema.parse(jsonSchema);
    JsonFactory factory = new JsonFactory();
    ObjectMapper mapper = new ObjectMapper(factory);

    this.data = mapper.readTree(new StringReader(jsonData));
  }
View Full Code Here

      .setRelatedids(Arrays.asList(1, 2, 3))
      .setTypeEnum(TypeEnum.c)
      .build();

    String json = foo.toString();
    JsonFactory factory = new JsonFactory();
    JsonParser parser = factory.createJsonParser(json);
    ObjectMapper mapper = new ObjectMapper();

    // will throw exception if string is not parsable json
    mapper.readTree(parser);
  }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.JsonFactory

Copyright © 2018 www.massapicom. 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.