<commit_before>package com.yeepay.g3.sdk.yop.unmarshaller;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Field;

/**
 * title: 保留Json对象为raw string的形式，不尝试解析它<br/>
 * description: 描述<br/>
 * Copyright: Copyright (c)2014<br/>
 * Company: 易宝支付(YeePay)<br/>
 *
 * @author wenkang.zhang
 * @version 1.0.0
 * @since 17/10/19 下午8:36
 */
public class KeepAsRawStringDeserializer extends JsonDeserializer<String> {

    private static final Logger LOGGER = Logger.getLogger(KeepAsRawStringDeserializer.class);

    @Override
    public String deserialize(JsonParser jp, DeserializationContext context) throws IOException {
        if (jp.isExpectedStartObjectToken() || jp.isExpectedStartArrayToken()) {
            String rawJson = getStringFromSource(jp.getCurrentLocation().getSourceRef());
            int startLocation = (int) jp.getCurrentLocation().getCharOffset();
            jp.skipChildren();
            int endLocation = (int) jp.getCurrentLocation().getCharOffset();
            return rawJson.substring(startLocation - 1, endLocation);
        } else if (jp.currentToken() == JsonToken.VALUE_STRING) {
            return "\"" + jp.getText() + "\"";
        } else {
            return jp.getText();
        }
    }
<commit_msg>fix: 兼容旧版json的token获取方法<commit_after>package com.yeepay.g3.sdk.yop.unmarshaller;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Field;

/**
 * title: 保留Json对象为raw string的形式，不尝试解析它<br/>
 * description: 描述<br/>
 * Copyright: Copyright (c)2014<br/>
 * Company: 易宝支付(YeePay)<br/>
 *
 * @author wenkang.zhang
 * @version 1.0.0
 * @since 17/10/19 下午8:36
 */
public class KeepAsRawStringDeserializer extends JsonDeserializer<String> {

    private static final Logger LOGGER = Logger.getLogger(KeepAsRawStringDeserializer.class);

    @Override
    public String deserialize(JsonParser jp, DeserializationContext context) throws IOException {
        if (jp.isExpectedStartObjectToken() || jp.isExpectedStartArrayToken()) {
            String rawJson = getStringFromSource(jp.getCurrentLocation().getSourceRef());
            int startLocation = (int) jp.getCurrentLocation().getCharOffset();
            jp.skipChildren();
            int endLocation = (int) jp.getCurrentLocation().getCharOffset();
            return rawJson.substring(startLocation - 1, endLocation);
        } else if (jp.getCurrentToken() == JsonToken.VALUE_STRING) {
            return "\"" + jp.getText() + "\"";
        } else {
            return jp.getText();
        }
    }

{'fraction_non_alphanumeric': 0.12092257001647447, 'fraction_numerical': 0.012520593080724876, 'mean_word_length': 3.7289719626168223, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '1894335', 'n_tokens_mistral': 991, 'n_tokens_neox': 963, 'n_words': 167}