package com.youngdatafan.dataintegration.core.util.json;
import java.io.Closeable;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import org.json.JSONException;
import org.json.JSONPointer;
import org.json.JSONPointerException;
import org.json.JSONPropertyIgnore;
import org.json.JSONPropertyName;
import org.json.JSONString;
import org.json.JSONWriter;
/**
* JSONLinkedObject.
*
* @author gavin
* @since 2020/2/16 1:07 下午
*/
public class JSONLinkedObject {
/**
* It is sometimes more convenient and less ambiguous to have a
* <code>NULL</code> object than to use Java's <code>null</code> value.
* <code>JSONObject.NULL.equals(null)</code> returns <code>true</code>.
* <code>JSONObject.NULL.toString()</code> returns <code>"null"</code>.
*/
public static final Object NULL = new Null();
/**
* 有序的LinkedHashMap.
*/
private final LinkedHashMap<String, Object> map;
/**
* Construct an empty JSONObject.
*/
public JSONLinkedObject() {
// LinkedHashMap is used on purpose to ensure that elements are unordered by
// the specification.
// JSON tends to be a portable transfer format to allows the container
// implementations to rearrange their items for a faster element
// retrieval based on associative access.
// Therefore, an implementation mustn't rely on the order of the item.
// this.map = new HashMap<String, Object>();
this.map = new LinkedHashMap<String, Object>();
}
/**
* Construct a JSONObject from a subset of another JSONObject. An array of
* strings is used to identify the keys that should be copied. Missing keys
* are ignored.
*
* @param jo A JSONObject.
* @param names An array of strings.
*/
public JSONLinkedObject(JSONLinkedObject jo, String[] names) {
this(names.length);
for (int i = 0; i < names.length; i += 1) {
try {
this.putOnce(names[i], jo.opt(names[i]));
} catch (Exception ignore) {
}
}
}
/**
* Construct a JSONObject from a JSONTokener.
*
* @param x A JSONTokener object containing the source string.
* @throws JSONException If there is a syntax error in the source string or a
* duplicated key.
*/
public JSONLinkedObject(JSONLinkedTokener x) throws JSONException {
this();
char c;
String key;
if (x.nextClean() != '{') {
throw x.syntaxError("A JSONObject text must begin with '{'");
}
for (; ; ) {
c = x.nextClean();
switch (c) {
case 0:
throw x.syntaxError("A JSONObject text must end with '}'");
case '}':
return;
default:
x.back();
key = x.nextValue().toString();
}
// The key is followed by ':'.
c = x.nextClean();
if (c != ':') {
throw x.syntaxError("Expected a ':' after a key");
}
// Use syntaxError(..) to include error location
if (key != null) {
// Check if key exists
if (this.opt(key) != null) {
// key already exists
throw x.syntaxError("Duplicate key \"" + key + "\"");
}
// Only add value if non-null
Object value = x.nextValue();
if (value != null) {
this.put(key, value);
}
}
// Pairs are separated by ','.
switch (x.nextClean()) {
case ';':
case ',':
if (x.nextClean() == '}') {
return;
}
x.back();
break;
case '}':
return;
default:
throw x.syntaxError("Expected a ',' or '}'");
}
}
}
/**
* Construct a JSONObject from a Map.
*
* @param m A map object that can be used to initialize the contents of
* the JSONObject.
* @throws JSONException If a value in the map is non-finite number.
* @throws NullPointerException If a key in the map is <code>null</code>
*/
public JSONLinkedObject(Map<?, ?> m) {
if (m == null) {
this.map = new LinkedHashMap<String, Object>();
} else {
this.map = new LinkedHashMap<String, Object>(m.size());
for (final Map.Entry<?, ?> e : m.entrySet()) {
if (e.getKey() == null) {
throw new NullPointerException("Null key.");
}
final Object value = e.getValue();
if (value != null) {
this.map.put(String.valueOf(e.getKey()), wrap(value));
}
}
}
}
/**
* Construct a JSONObject from an Object using bean getters. It reflects on
* all of the public methods of the object. For each of the methods with no
* parameters and a name starting with <code>"get"</code> or
* <code>"is"</code> followed by an uppercase letter, the method is invoked,
* and a key and the value returned from the getter method are put into the
* new JSONObject.
*
* <p>The key is formed by removing the <code>"get"</code> or <code>"is"</code>
* prefix. If the second remaining character is not upper case, then the
* first character is converted to lower case.
*
* <p>Methods that are <code>static</code>, return <code>void</code>,
* have parameters, or are "bridge" methods, are ignored.
*
* <p>For example, if an object has a method named <code>"getName"</code>, and
* if the result of calling <code>object.getName()</code> is
* <code>"Larry Fine"</code>, then the JSONObject will contain
* <code>"name": "Larry Fine"</code>.
*
* <p>The {@link JSONPropertyName} annotation can be used on a bean getter to
* override key name used in the JSONObject. For example, using the object
* above with the <code>getName</code> method, if we annotated it with:
* <pre>
* @JSONPropertyName("FullName")
* public String getName() { return this.name; }
* </pre>
* The resulting JSON object would contain <code>"FullName": "Larry Fine"</code>
*
* <p>Similarly, the {@link JSONPropertyName} annotation can be used on non-
* <code>get</code> and <code>is</code> methods. We can also override key
* name used in the JSONObject as seen below even though the field would normally
* be ignored:
* <pre>
* @JSONPropertyName("FullName")
* public String fullName() { return this.name; }
* </pre>
* The resulting JSON object would contain <code>"FullName": "Larry Fine"</code>
*
* <p>The {@link JSONPropertyIgnore} annotation can be used to force the bean property
* to not be serialized into JSON. If both {@link JSONPropertyIgnore} and
* {@link JSONPropertyName} are defined on the same method, a depth comparison is
* performed and the one closest to the concrete class being serialized is used.
* If both annotations are at the same level, then the {@link JSONPropertyIgnore}
* annotatio
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目资源】: 包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。 包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。 【项目质量】: 所有源码都经过严格测试,可以直接运行。 功能在确认正常工作后才上传。 【适用人群】: 适用于希望学习不同技术领域的小白或进阶学习者。 可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【附加价值】: 项目具有较高的学习借鉴价值,也可直接拿来修改复刻。 对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。 【沟通交流】: 有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
毕设&课设&项目&实训-基于kettle实现的web版数据集成平台,致力于提供web可拖拽的数据集成平台。.zip (1645个子文件)
.babelrc 230B
mvnw.cmd 6KB
mysqld.cnf 2KB
index.css 1.28MB
date-picker.css 83KB
cascader.css 81KB
pagination.css 73KB
select.css 63KB
transfer.css 60KB
time-picker.css 58KB
table.css 51KB
message-box.css 50KB
time-select.css 42KB
slider.css 42KB
cascader-panel.css 41KB
col.css 38KB
dropdown.css 36KB
home.css 35KB
table-column.css 34KB
autocomplete.css 33KB
tree.css 30KB
iconfont.css 28KB
calendar.css 27KB
upload.css 26KB
base.css 24KB
tabs.css 24KB
input-number.css 23KB
button.css 21KB
menu.css 19KB
icon.css 17KB
checkbox.css 16KB
color-picker.css 14KB
input.css 13KB
dialog.css 13KB
collapse.css 13KB
select-dropdown.css 13KB
popover.css 12KB
step.css 12KB
radio.css 11KB
drawer.css 11KB
tag.css 11KB
radio-button.css 10KB
image.css 9KB
form.css 8KB
carousel.css 8KB
tooltip.css 8KB
progress.css 8KB
link.css 8KB
alert.css 7KB
message.css 7KB
switch.css 7KB
loading.css 7KB
notification.css 7KB
popper.css 7KB
timeline-item.css 7KB
scrollbar.css 6KB
breadcrumb.css 6KB
carousel-item.css 6KB
display.css 6KB
row.css 6KB
badge.css 6KB
divider.css 6KB
page-header.css 6KB
rate.css 6KB
avatar.css 6KB
card.css 5KB
option-group.css 5KB
option.css 5KB
backtop.css 5KB
popconfirm.css 5KB
main.css 5KB
timeline.css 5KB
footer.css 5KB
header.css 5KB
radio-group.css 5KB
index.css 5KB
spinner.css 4KB
reset.css 3KB
container.css 3KB
steps.css 3KB
aside.css 3KB
element-variables.css 2KB
font.css 114B
infinite-scroll.css 0B
menu-item.css 0B
breadcrumb-item.css 0B
infiniteScroll.css 0B
button-group.css 0B
submenu.css 0B
menu-item-group.css 0B
checkbox-button.css 0B
tab-pane.css 0B
checkbox-group.css 0B
dropdown-menu.css 0B
dropdown-item.css 0B
collapse-item.css 0B
form-item.css 0B
docker-compose-linux-x86_64 25.23MB
dockerfile 1KB
Dockerfile 747B
共 1645 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
妄北y
- 粉丝: 9833
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功