Package net.minidev.json

Examples of net.minidev.json.JSONObject


        super(config);
    }

    @Override
    public long extractTimestampMillis(final Message message) throws ClassCastException {
        JSONObject jsonObject = (JSONObject) JSONValue.parse(message.getPayload());
        if (jsonObject != null) {
            Object fieldValue = jsonObject.get(mConfig.getMessageTimestampName());
            if (fieldValue != null) {
                long timestamp = 0;
                if (fieldValue instanceof Number) {
                    timestamp = ((Number) fieldValue).longValue();
                } else {
View Full Code Here


        timestamp = loggingEvent.getTimeStamp();
        exceptionInformation = new HashMap<String, Object>();
        mdc = loggingEvent.getProperties();
        ndc = loggingEvent.getNDC();

        logstashEvent = new JSONObject();
        String whoami = this.getClass().getSimpleName();

        /**
         * All v1 of the event format requires is
         * "@timestamp" and "@version"
View Full Code Here

        fieldData = new HashMap<String, Object>();
        exceptionInformation = new HashMap<String, Object>();
        mdc = loggingEvent.getProperties();
        ndc = loggingEvent.getNDC();

        logstashEvent = new JSONObject();

        logstashEvent.put("@source_host", hostname);
        logstashEvent.put("@message", loggingEvent.getRenderedMessage());
        logstashEvent.put("@timestamp", dateFormat(timestamp));
View Full Code Here

  public static Vo parseJsonFile(String filename) {
    Blob b = new Blob(filename);
    return parseJson(b.toString());
  }
  public static Vo parseJson(String json) {
    JSONObject o = null;
    try {
        JSONParser p = new JSONParser();
        o = (JSONObject)p.parse(json);   
    } catch (Exception e) { fail(e); }
    return (Vo)parseObject(o);
View Full Code Here

 
 
  @Override
  public JSONObject toJSONObject() {
   
    JSONObject out = new JSONObject();
   
    // Result and error are mutually exclusive
    if (error != null) {
      out.put("error", error.toJSONObject());
    }
    else {
      out.put("result", result);
    }
   
    out.put("id", id);
   
    out.put("jsonrpc", "2.0");
   
   
    Map <String,Object> nonStdAttributes = getNonStdAttributes();
   
    if (nonStdAttributes != null) {
   
      for (final Map.Entry<String,Object> attr: nonStdAttributes.entrySet())
        out.put(attr.getKey(), attr.getValue());
    }
   
    return out;
  }
View Full Code Here

   *
   * @return A JSON object representing this error object.
   */
  public JSONObject toJSONObject() {
 
    JSONObject out = new JSONObject();
   
    out.put("code", code);
    out.put("message", super.getMessage());
    if (data != null)
      out.put("data", data);
       
    return out;
  }
View Full Code Here

 
 
  @Override
  public JSONObject toJSONObject() {
 
    JSONObject notf = new JSONObject();
   
    notf.put("method", method);
   
    // The params can be omitted if none
    switch (getParamsType()) {

      case ARRAY:
        notf.put("params", positionalParams);
        break;

      case OBJECT:
        notf.put("params", namedParams);
        break;
    }
   
    notf.put("jsonrpc", "2.0");
   
   
    Map <String,Object> nonStdAttributes = getNonStdAttributes();
   
    if (nonStdAttributes != null) {
   
      for (final Map.Entry<String,Object> attr: nonStdAttributes.entrySet())
        notf.put(attr.getKey(), attr.getValue());
    }
   
    return notf;
  }
View Full Code Here

 
 
  @Override
  public JSONObject toJSONObject() {
 
    JSONObject req = new JSONObject();
   
    req.put("method", method);
   
    // The params can be omitted if none
    switch (getParamsType()) {

      case ARRAY:
        req.put("params", positionalParams);
        break;

      case OBJECT:
        req.put("params", namedParams);
        break;
    }
   
    req.put("id", id);
   
    req.put("jsonrpc", "2.0");
   
    Map <String,Object> nonStdAttributes = getNonStdAttributes();
   
    if (nonStdAttributes != null) {
   
      for (final Map.Entry<String,Object> attr: nonStdAttributes.entrySet())
        req.put(attr.getKey(), attr.getValue());
    }
   
    return req;
  }
View Full Code Here

        additionalFields.put("exception", myExceptionInformation);

    }

    public String toJson() {
        JSONObject logstashEvent = new JSONObject();

        logstashEvent.put("@source_host", source_host);
        logstashEvent.put("@source", source);
        logstashEvent.put("@source_path", source_path);
        logstashEvent.put("@message", message);
        logstashEvent.put("@tags", tags);
        logstashEvent.put("@fields",additionalFields);

        return logstashEvent.toJSONString();
    }
View Full Code Here

    public String toJson() {
        String ident = this.getIdentity();
        String[] tagz = this.getTags();
        LoggingEventData event = this.getEventData();
        JSONObject jsonEvent = new JSONObject();

        // Convert existing LoggingEventData to JsonObject
        // So we can inject some additional data

        jsonEvent.put("fqn", event.fqn);
        jsonEvent.put("identity", ident);

        if (!(null == tagz)) {
            jsonEvent.put("tags",tagz);
        }

        return jsonEvent.toJSONString();
    }
View Full Code Here

TOP

Related Classes of net.minidev.json.JSONObject

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.