kit

json,xml,httpclient etc.

License

License

GroupId

GroupId

com.github.dingey
ArtifactId

ArtifactId

kit
Last Version

Last Version

1.9
Release Date

Release Date

Type

Type

jar
Description

Description

kit
json,xml,httpclient etc.
Project URL

Project URL

https://github.com/dingey/kit
Source Code Management

Source Code Management

https://github.com/dingey/kit

Download kit

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.dingey/kit/ -->
<dependency>
    <groupId>com.github.dingey</groupId>
    <artifactId>kit</artifactId>
    <version>1.9</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.dingey/kit/
implementation 'com.github.dingey:kit:1.9'
// https://jarcasting.com/artifacts/com.github.dingey/kit/
implementation ("com.github.dingey:kit:1.9")
'com.github.dingey:kit:jar:1.9'
<dependency org="com.github.dingey" name="kit" rev="1.9">
  <artifact name="kit" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.dingey', module='kit', version='1.9')
)
libraryDependencies += "com.github.dingey" % "kit" % "1.9"
[com.github.dingey/kit "1.9"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

kit

toolkit simple:xml,json,httpconnection etc。

开始使用,引入依赖

<dependency>
  <groupId>com.github.dingey</groupId>
  <artifactId>kit</artifactId>
  <version>1.4</version>
</dependency>

json

json字符串转Object

class Man{
  int id;
  String n;
}

String json = "{\"id\":1,\"n\":\"alice\"}";
//方法1
Man m1 = Json.fromJson(json , Man.class);
//方法2
Man m2 = new Json().toObject(json , Man.class);

转换成json

Man m=new Man();
//方法1
String json1 = Json.toJsonString(m);
//方法2
String json2 = new Json().toJson(m);

设置时间格式和是否驼峰转下划线

Json j=new Json();
j.setDateFormat("yyyy-MM-dd HH:mm:ss");
j.setCamelCaseToUnderscores(true);

转换成map和list结构的对象

Json.getJson().toObject(json);

xml

Xml.toObject(String xml,Class<T> cl);
Xml.toXml(T o);

XmlBuilder.parse(String xml);

JAXB
XmlUtil.toXml(T o);
XmlUtil.fromXml(String xml, Class<T> target);

httpclient

http工具类

postForm(String, Map<Object, Object>);
postMultipartForm(String, Map<Object, Object>);
postJson(String, String);
postXml(String, String);
get(String);

Versions

Version
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0