<commit_before>package com.ctrip.ops.sysdev.decoder;

import java.util.HashMap;
import java.util.Map;

import org.joda.time.DateTime;
import org.json.simple.JSONValue;
import org.json.simple.parser.ParseException;

import org.apache.log4j.Logger;

public class JsonDecoder implements IDecode {
    private static final Logger logger = Logger
            .getLogger(JsonDecoder.class.getName());

    @SuppressWarnings("unchecked")
    @Override
    public Map<String, Object> decode(final String message) {
        Map<String, Object> event = null;
        try {
            event = (HashMap<String, Object>) JSONValue
                    .parseWithException(message);
        } catch (Exception e) {
            logger.warn("failed to json parse message to a Map");
            event = new HashMap<String, Object>() {
                {
                    put("message", message);
                    put("@timestamp", DateTime.now());
                }
            };
        }

        if (event == null) {
            event = new HashMap<String, Object>() {
                {
                    put("message", message);
                    put("@timestamp", DateTime.now());
                }
            };
        } else {
            if (!event.containsKey("@timestamp")) {
                event.put("@timestamp", DateTime.now());
            }
        }
        return event;
    }
}<commit_msg>split json.parse and convert to map<commit_after>package com.ctrip.ops.sysdev.decoder;

import java.util.HashMap;
import java.util.Map;

import org.jcodings.util.Hash;
import org.joda.time.DateTime;
import org.json.simple.JSONValue;
import org.json.simple.parser.ParseException;

import org.apache.log4j.Logger;

public class JsonDecoder implements IDecode {
    private static final Logger logger = Logger
            .getLogger(JsonDecoder.class.getName());

    @SuppressWarnings("unchecked")
    @Override
    public Map<String, Object> decode(final String message) {
        Map<String, Object> event = null;
        Object e = null;
        try {
            e = JSONValue
                    .parseWithException(message);
        } catch (ParseException exception) {
            logger.warn("failed to json parse message");
            logger.warn(exception.getLocalizedMessage());
            event = new HashMap<String, Object>() {
                {
                    put("message", message);
                    put("@timestamp", DateTime.now());
                }
            };
        }

        if (event == null) {
            event = new HashMap<String, Object>() {
                {
                    put("message", message);
                    put("@timestamp", DateTime.now());
                }
            };
        } else {
            try {
                event = (HashMap<String, Object>) e;
                if (!event.containsKey("@timestamp")) {
                    event.put("@timestamp", DateTime.now());
                }
            } catch (Exception exception) {
                logger.warn("failed to convert event to Map object");
                logger.warn(exception.getLocalizedMessage());
                event = new HashMap<String, Object>() {
                    {
                        put("message", message);
                        put("@timestamp", DateTime.now());
                    }
                };
            }
        }

        return event;
    }
}
{'fraction_non_alphanumeric': 0.11582334015794092, 'fraction_numerical': 0.000584966364434045, 'mean_word_length': 1.5850340136054422, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '12945', 'n_tokens_mistral': 865, 'n_tokens_neox': 833, 'n_words': 192}