mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix doc
This commit is contained in:
parent
f7a2741aa3
commit
1c18ccf660
@ -210,17 +210,6 @@ public interface JSON extends Serializable {
|
||||
return this.toJSONString(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出JSON字符串
|
||||
*
|
||||
* @param indentFactor 每层缩进空格数
|
||||
* @return JSON字符串
|
||||
* @throws JSONException 包含非法数抛出此异常
|
||||
*/
|
||||
default String toJSONString(final int indentFactor) throws JSONException {
|
||||
return toJSONString(indentFactor, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出JSON字符串
|
||||
*
|
||||
@ -235,6 +224,17 @@ public interface JSON extends Serializable {
|
||||
return jsonWriter.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出JSON字符串
|
||||
*
|
||||
* @param indentFactor 每层缩进空格数
|
||||
* @return JSON字符串
|
||||
* @throws JSONException 包含非法数抛出此异常
|
||||
*/
|
||||
default String toJSONString(final int indentFactor) throws JSONException {
|
||||
return toJSONString(indentFactor, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将JSON内容写入Writer<br>
|
||||
* Warning: This method assumes that the data structure is acyclical.
|
||||
|
@ -27,7 +27,6 @@ import org.dromara.hutool.json.serializer.impl.IterTypeAdapter;
|
||||
import org.dromara.hutool.json.writer.JSONWriter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* JSON数组<br>
|
||||
@ -258,21 +257,6 @@ public class JSONArray extends ListWrapper<JSON> implements JSON, JSONGetter<Int
|
||||
return this.toJSONString(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回JSON字符串<br>
|
||||
* 支持过滤器,即选择哪些字段或值不写出
|
||||
*
|
||||
* @param indentFactor 每层缩进空格数
|
||||
* @param predicate 过滤器,可以修改值,key(index)无法修改,{@link Predicate#test(Object)}为{@code true}保留
|
||||
* @return JSON字符串
|
||||
* @since 5.7.15
|
||||
*/
|
||||
public String toJSONString(final int indentFactor, final Predicate<MutableEntry<Object, Object>> predicate) {
|
||||
final JSONWriter jsonWriter = JSONWriter.of(new StringBuilder(), indentFactor, 0, this.config).setPredicate(predicate);
|
||||
this.write(jsonWriter);
|
||||
return jsonWriter.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final JSONWriter writer) throws JSONException {
|
||||
writer.beginArray();
|
||||
|
@ -177,4 +177,6 @@ public class JSONFactory {
|
||||
return mapper.toBean(json, type);
|
||||
}
|
||||
// endregion
|
||||
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class JSONMapper implements Serializable {
|
||||
private static final long serialVersionUID = -6714488573738940582L;
|
||||
|
||||
/**
|
||||
* 创建ObjectMapper
|
||||
* 创建JSONMapper
|
||||
*
|
||||
* @param jsonConfig 来源对象
|
||||
* @param predicate 键值对过滤编辑器,可以通过实现此接口,完成解析前对键值对的过滤和修改操作,{@link Predicate#test(Object)}为{@code true}保留
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2024 Hutool Team and hutool.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.dromara.hutool.json.writer;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* JSON的值自定义写出,通过自定义实现此接口,实现对象自定义写出字符串形式<br>
|
||||
* 如自定义的一个CustomBean,我只希望输出id的值,此时自定义此接口。<br>
|
||||
* 其中{@link ValueWriter#test(Object)}负责判断何种对象使用此规则,{@link ValueWriter#write(JSONWriter, Object)}负责写出规则。
|
||||
*
|
||||
* @author looly
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public interface ValueWriter extends Predicate<Object> {
|
||||
|
||||
/**
|
||||
* 使用{@link JSONWriter} 写出对象
|
||||
*
|
||||
* @param writer {@link JSONWriter}
|
||||
* @param value 被写出的值
|
||||
*/
|
||||
void write(JSONWriter writer, Object value);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user