Search in sources :

Example 66 with IJsonObject

use of com.helger.json.IJsonObject in project ph-web by phax.

the class LoggingRequest method getAsJson.

@Nonnull
public IJsonObject getAsJson() {
    final JsonObject ret = new JsonObject();
    if (m_sSender != null)
        ret.add("sender", m_sSender);
    if (m_sMethod != null)
        ret.add("method", m_sMethod);
    if (m_sPath != null)
        ret.add("path", m_sPath);
    if (m_aParams != null)
        ret.addJson("params", new JsonObject().addAll(m_aParams));
    if (m_aHeaders != null) {
        final IJsonObject aHeaders = new JsonObject();
        m_aHeaders.forEachSingleHeader(aHeaders::add, true);
        ret.addJson("headers", aHeaders);
    }
    if (m_sBody != null)
        ret.add("body", m_sBody);
    return ret;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Example 67 with IJsonObject

use of com.helger.json.IJsonObject in project ph-web by phax.

the class LoggingResponse method getAsJson.

@Nonnull
public IJsonObject getAsJson() {
    final JsonObject ret = new JsonObject();
    if (m_nStatus != 0)
        ret.add("status", m_nStatus);
    if (m_aHeaders != null) {
        final IJsonObject aHeaders = new JsonObject();
        m_aHeaders.forEachSingleHeader(aHeaders::add, true);
        ret.addJson("headers", aHeaders);
    }
    if (m_sBody != null)
        ret.add("body", m_sBody);
    return ret;
}
Also used : IJsonObject(com.helger.json.IJsonObject) IJsonObject(com.helger.json.IJsonObject) JsonObject(com.helger.json.JsonObject) Nonnull(javax.annotation.Nonnull)

Aggregations

IJsonObject (com.helger.json.IJsonObject)67 JsonObject (com.helger.json.JsonObject)38 Nonnull (javax.annotation.Nonnull)34 IJsonArray (com.helger.json.IJsonArray)16 JsonArray (com.helger.json.JsonArray)16 Test (org.junit.Test)15 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)7 IError (com.helger.commons.error.IError)6 StopWatch (com.helger.commons.timing.StopWatch)5 IJson (com.helger.json.IJson)5 JsonWriter (com.helger.json.serialize.JsonWriter)5 Map (java.util.Map)5 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)4 ZonedDateTime (java.time.ZonedDateTime)4 Nullable (javax.annotation.Nullable)4 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)3 CommonsLinkedHashMap (com.helger.commons.collection.impl.CommonsLinkedHashMap)3 ICommonsList (com.helger.commons.collection.impl.ICommonsList)3 ICommonsMap (com.helger.commons.collection.impl.ICommonsMap)3 SimpleLocation (com.helger.commons.location.SimpleLocation)3