@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 testReadFromMapFullJson() throws Exception {
        RawMessage json = new RawMessage("{\"store\":{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99,\"isbn\":\"0-553-21311-3\"}],\"bicycle\":{\"color\":\"red\",\"price\":19.95}}}".getBytes(StandardCharsets.UTF_8));
        String path = "$.store.book[?(@.category == 'fiction')].author";

        Message result = new JsonPathCodec(configOf(CK_PATH, path, CK_FLATTEN, true), objectMapperProvider.get(), messageFactory).decode(json);
        assertThat(result.getField("store.book1.author")).isEqualTo("\"Evelyn Waugh\"");
    }