<commit_before>package com.github.dreamhead.moco.handler;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dreamhead.moco.HttpRequest;
import com.github.dreamhead.moco.Request;
import com.github.dreamhead.moco.model.MessageContent;

public class JsonResponseHandler extends AbstractContentResponseHandler {
    private final ObjectMapper mapper = new ObjectMapper();
    private final Object pojo;


    public JsonResponseHandler(final Object pojo) {
        this.pojo = pojo;
    }

    @Override
    protected MessageContent responseContent(final Request request) {
        try {
            return MessageContent.content().withContent(mapper.writeValueAsBytes(pojo)).build();
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected String getContentType(HttpRequest request) {
        return "application/json";
    }
}<commit_msg>replaced json pojo implementation in json response handler with toJson in jsons<commit_after>package com.github.dreamhead.moco.handler;

import com.github.dreamhead.moco.HttpRequest;
import com.github.dreamhead.moco.Request;
import com.github.dreamhead.moco.model.MessageContent;

import static com.github.dreamhead.moco.util.Jsons.toJson;

public class JsonResponseHandler extends AbstractContentResponseHandler {
    private final Object pojo;


    public JsonResponseHandler(final Object pojo) {
        this.pojo = pojo;
    }

    @Override
    protected MessageContent responseContent(final Request request) {
        return MessageContent.content().withContent(toJson(this.pojo)).build();
    }

    @Override
    protected String getContentType(HttpRequest request) {
        return "application/json";
    }
}
{'fraction_non_alphanumeric': 0.08383894098179813, 'fraction_numerical': 0.0, 'mean_word_length': 3.9562841530054644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7491184', 'n_tokens_mistral': 506, 'n_tokens_neox': 478, 'n_words': 107}