src/main/java/com/arpnetworking/logback/serialization/steno/ObjectAsJsonSerialziationStrategy.java
public String serialize(
            final ILoggingEvent event,
            final String eventName,
            final String jsonData)
            throws Exception {

        final StringWriter jsonWriter = new StringWriter();
        final JsonGenerator jsonGenerator = _jsonFactory.createGenerator(jsonWriter);

        // Start wrapper
        StenoSerializationHelper.startStenoWrapper(event, eventName, jsonGenerator, _objectMapper);

        // Write event data
        jsonGenerator.writeFieldName("data");
        if (jsonData == null) {
            jsonGenerator.writeStartObject();
            jsonGenerator.writeEndObject();
        } else {
            jsonGenerator.writeRawValue(jsonData);
        }
        // TODO(vkoskela): Support writing null objects as-is via configuration [ISSUE-4]
        // e.g. "data":null -- although this is not supported by the current Steno specification

        // Output throwable
        StenoSerializationHelper.writeThrowable(event.getThrowableProxy(), jsonGenerator, _objectMapper);

        // End wrapper
        StenoSerializationHelper.endStenoWrapper(event, eventName, jsonGenerator, _objectMapper, _encoder);

        return jsonWriter.toString();
    }
public String serialize(
            final ILoggingEvent event,
            final String eventName,
            final String jsonData)
            throws Exception {

        final StringWriter jsonWriter = new StringWriter();
        final JsonGenerator jsonGenerator = _jsonFactory.createGenerator(jsonWriter);

        // Start wrapper
        StenoSerializationHelper.startStenoWrapper(event, eventName, jsonGenerator, _objectMapper);

        // Write event data
        jsonGenerator.writeFieldName("data");
        if (jsonData == null) {
            jsonGenerator.writeStartObject();
            jsonGenerator.writeEndObject();
        } else {
            jsonGenerator.writeRawValue(jsonData);
        }
        // TODO(vkoskela): Support writing null objects as-is via configuration [ISSUE-4]
        // e.g. "data":null -- although this is not supported by the current Steno specification

        // Output throwable
        StenoSerializationHelper.writeThrowable(event.getThrowableProxy(), jsonGenerator, _objectMapper);

        // End wrapper
        StenoSerializationHelper.endStenoWrapper(event, eventName, jsonGenerator, _objectMapper, _encoder);

        return jsonWriter.toString();
    }
public String serialize ( final ILoggingEvent event , final String eventName , final String jsonData ) throws Exception { final StringWriter jsonWriter = new StringWriter ( ) ; final JsonGenerator jsonGenerator = _jsonFactory . createGenerator ( jsonWriter ) ; // Start wrapper StenoSerializationHelper . startStenoWrapper ( event , eventName , jsonGenerator , _objectMapper ) ; // Write event data jsonGenerator . writeFieldName ( "data" ) ; if ( jsonData == null ) { jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeEndObject ( ) ; } else { jsonGenerator . writeRawValue ( jsonData ) ; } // TODO(vkoskela): Support writing null objects as-is via configuration [ISSUE-4] // e.g. "data":null -- although this is not supported by the current Steno specification // Output throwable StenoSerializationHelper . writeThrowable ( event . getThrowableProxy ( ) , jsonGenerator , _objectMapper ) ; // End wrapper StenoSerializationHelper . endStenoWrapper ( event , eventName , jsonGenerator , _objectMapper , _encoder ) ; return jsonWriter . toString ( ) ; }
Serialize an event.

@param event The event.
@param eventName The event name.
@param jsonData The message data as serialized JSON.
@return Serialization of message as a <code>String</code>.
@throws Exception Serialization may throw any <code>Exception</code>.
Serialize an event .