Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.writeValue()


      //The getMethod on this _dbusEventBuffer should be only called by the ConfigLoader
      if(_dbusEventBuffer!=null)
        {
          ObjectMapper mapperDbus = new ObjectMapper();
          StringWriter writerDbus = new StringWriter();
          mapperDbus.writeValue(writerDbus, _dbusEventBuffer);
          jsonObj.put("dbusEventBuffer", new JSONObject(writerDbus.toString()));
        }
      else
        jsonObj.put("dbusEventBuffer", JSONObject.NULL);
View Full Code Here


  public static PhysicalSourceConfig fromMap(Map<String,Object> map) throws JsonGenerationException, JsonMappingException, IOException
  {

    ObjectMapper mapper = new ObjectMapper();
    StringWriter writer = new StringWriter();
    mapper.writeValue(writer, map);
    String str =  writer.toString();
    return fromString(str);
  }

View Full Code Here

  public static String generateRegisterResponse(RegisterResponseEntry... entries)
      throws JsonGenerationException, JsonMappingException, IOException
  {
    ObjectMapper mapper = new ObjectMapper();
    StringWriter w = new StringWriter();
    mapper.writeValue(w, entries);
    w.close();
    return w.toString();
  }

  public static String generateRegisterResponseV4(HashMap<String, List<Object>> entries)
View Full Code Here

  public static String generateRegisterResponseV4(HashMap<String, List<Object>> entries)
      throws JsonGenerationException, JsonMappingException, IOException
  {
    ObjectMapper mapper = new ObjectMapper();
    StringWriter w = new StringWriter();
    mapper.writeValue(w, entries);
    w.close();
    return w.toString();
  }

  public static ChannelBuffer streamToChannelBuffer(DbusEventBuffer buf, Checkpoint cp,
View Full Code Here

        else
        {
          LOG.debug("No metadata schema available; sending v4 /register response without.");
        }
        // TODO:  figure out how to retrieve key schemas and include via RegisterResponseEntry.KEY_SCHEMAS_KEY
        mapper.writeValue(out, responseMap);
      }
      else // fall back to old style (v2/v3 response)
      {
        mapper.writeValue(out, registeredSources);
      }
View Full Code Here

        // TODO:  figure out how to retrieve key schemas and include via RegisterResponseEntry.KEY_SCHEMAS_KEY
        mapper.writeValue(out, responseMap);
      }
      else // fall back to old style (v2/v3 response)
      {
        mapper.writeValue(out, registeredSources);
      }

      ChunkedWritableByteChannel responseContent = request.getResponseContent();
      byte[] resultBytes = out.toString().getBytes(Charset.defaultCharset());
      responseContent.addMetadata(DatabusHttpHeaders.DBUS_CLIENT_RELAY_PROTOCOL_VERSION_HDR,
View Full Code Here

  private String mapToJsonStr(Map<String,Object> map) throws JsonGenerationException, JsonMappingException, IOException
  {

    ObjectMapper mapper = new ObjectMapper();
    StringWriter writer = new StringWriter();
    mapper.writeValue(writer, map);
    String str =  writer.toString();
    return str;
  }
 
  @Test
View Full Code Here

    {
      StringWriter out = new StringWriter();
      ObjectMapper objMapper = new ObjectMapper();
      try
      {
        objMapper.writeValue(out, this);
        _jsonString = out.toString();
      }
      catch (Exception e)
      {
        _jsonString = "serialiationError";
View Full Code Here

    Collection<LogicalSource> sources = _relay.getSourcesIdNameRegistry().getAllSources();
    if (1 == protoVersion)
    {
      ArrayList<IdNamePair> sourcePairs = new ArrayList<IdNamePair>(sources.size());
      for (LogicalSource source: sources) sourcePairs.add(new IdNamePair(source.getId().longValue(), source.getName()));
      mapper.writeValue(out, sourcePairs);
    }
    else if (2 == protoVersion) mapper.writeValue(out, sources);
    else throw new InvalidRequestParamValueException(COMMAND_NAME, VERSION_PARAM_NAME,
                                                     Integer.toString(protoVersion));
View Full Code Here

    {
      ArrayList<IdNamePair> sourcePairs = new ArrayList<IdNamePair>(sources.size());
      for (LogicalSource source: sources) sourcePairs.add(new IdNamePair(source.getId().longValue(), source.getName()));
      mapper.writeValue(out, sourcePairs);
    }
    else if (2 == protoVersion) mapper.writeValue(out, sources);
    else throw new InvalidRequestParamValueException(COMMAND_NAME, VERSION_PARAM_NAME,
                                                     Integer.toString(protoVersion));


    byte[] resultBytes = out.toString().getBytes(Charset.defaultCharset());
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.