@Nullable
    @Override
    public Message decode(@Nonnull RawMessage rawMessage) {
        Map<String, Object> fields = new HashMap<>();
        if (flatten) {
            final String json = new String(rawMessage.getPayload(), charset);
            try {
                fields = flatten(json);
            } catch (JsonFlattenException e) {
                LOG.warn("JSON contains type not supported by flatten method.", e);
            } catch (JsonProcessingException e) {
                LOG.warn("Could not parse JSON.", e);
            }
        } else {
            if (jsonPath == null) {
                return null;
            }
            final String json = new String(rawMessage.getPayload(), charset);
            fields = read(json);
        }

        final Message message = messageFactory.createMessage(buildShortMessage(fields),
                configuration.getString(CK_SOURCE),
                rawMessage.getTimestamp());
        message.addFields(fields);
        return message;
    }
@Test
    public void testReadResultingInSingleStringFullJson() throws Exception {
        RawMessage json = new RawMessage("{\"url\":\"https://api.github.com/repos/Graylog2/graylog2-server/releases/assets/22660\",\"download_count\":76185,\"id\":22660,\"name\":\"graylog2-server-0.20.0-preview.1.tgz\",\"label\":\"graylog2-server-0.20.0-preview.1.tgz\",\"content_type\":\"application/octet-stream\",\"state\":\"uploaded\",\"size\":38179285,\"updated_at\":\"2013-09-30T20:05:46Z\"}".getBytes(StandardCharsets.UTF_8));
        String path = "$.state";

        Message result = new JsonPathCodec(configOf(CK_PATH, path, CK_FLATTEN, true), objectMapperProvider.get(), messageFactory).decode(json);
        assertThat(result.getField("state")).isEqualTo("\"uploaded\"");
    }