1 Star 0 Fork 19

忆江南 / okjson

forked from calvinwilliams / okjson 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

okjson - JAVA编写的小巧、高效、灵活的JSON处理器(JSON解析器+JSON生成器)

1. 概述

okjson是用JAVA编写的JSON处理器(JSON解析器+JSON生成器)。

它能帮助开发者把一段JSON文本中的数据映射到实体类中,或由一个实体类生成一段JSON文本。

它小巧,源码只有一个类文件和一个注解类文件,方便架构师嵌入到项目/框架中去。

它高效,比号称全世界最快的fastjson还要快。

它灵活,不对映射实体类有各种各样约束要求。

一个好工具就是简单、朴素的。

2. 一个示例

来一个简单示例感受一下(所有代码可在源码包src\test\java\xyz\calvinwilliams\okjson里找到)

2.1. 编写JSON文件

demo.json

{
	"userName" : "Calvin" ,
	"email" : "calvinwilliams@163.com" ,
	"userExtInfo" : {
		"gender" : "M" ,
		"age" : 30 ,
		"address" : "I won't tell you"
	} ,
	"interestGroupList" : [
		"Programing", "Playing game", "Reading", "Sleeping"
	] ,
	"borrowDetailList" : [
		{
			"bookName" : "Thinking in JAVA" ,
			"author" : "Bruce Eckel" ,
			"borrowDate" : "2014-01-02" ,
			"borrowTime" : "17:30:00"
		} ,
		{
			"bookName" : "Thinking in C++" ,
			"author" : "Bruce Eckel too" ,
			"borrowDate" : "2014-02-04" ,
			"borrowTime" : "17:35:00"
		} ,
		{
			"bookName" : "Thinking in okjson" ,
			"author" : "It's me !!!" ,
			"borrowDate" : "2014-03-06" ,
			"borrowTime" : "17:40:00"
		}
	]
}

2.2. 编写实体类

DemoUserClass.java

package xyz.calvinwilliams.okjson;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.LinkedList;

public class DemoUserClass {
	String				userName ;
	String				email ;
	UserExtInfo			userExtInfo ;
	LinkedList<String>			interestGroupList ;
	LinkedList<BorrowDetail>	borrowDetailList ;
}

class UserExtInfo {
	String				gender ;
	int					age ;
	String				address ;
}

class BorrowDetail {
	String				bookName ;
	String				author ;
	@OkJsonDateTimeFormatter(format="yyyy-MM-dd")
	LocalDate			borrowDate ;
	@OkJsonDateTimeFormatter(format="HH:mm:ss")
	LocalTime			borrowTime ;
}

2.3. 编写示例代码

读入JSON文件,映射所有字段数据到实体类属性中去

package xyz.calvinwilliams.okjson;

import java.time.format.DateTimeFormatter;

public class Demo {

	public static void printDemoUser( DemoUserClass demoUser ) {
		...
	}
	
	public static void main(String[] args) {
		DemoUserClass	demoUser = new DemoUserClass() ;
		
		System.out.println( "OKJSON.stringToObject ..." );
		demoUser = OKJSON.fileToObject( "demo.json", DemoUserClass.class, OKJSON.OKJSON_OTIONS_DIRECT_ACCESS_PROPERTY_ENABLE ) ;
		if( demoUser == null ) {
			System.out.println( "OKJSON.stringToObject failed["+OKJSON.getErrorCode()+"]["+OKJSON.getErrorDesc()+"]" );
			return;
		} else {
			System.out.println( "OKJSON.stringToObject ok" );
			printDemoUser( demoUser );
		}
	}
}

调用一个静态方法就能把JSON所有字段数据都映射到实体类属性中去,是不是很简单。

我的其它开源产品都用它装载配置文件,小巧、高效、灵活。

3. 使用参考

3.1. 静态方法

3.1.1. OKJSON.getErrorCode

方法原型 Integer getErrorCode();
方法说明 当JSON解析或生成失败后,调用此方法获取错误码
返回值 最近错误码

3.1.2. OKJSON.getErrorDesc

方法原型 String getErrorDesc();
方法说明 当JSON解析或生成失败后,调用此方法获取错误描述
返回值 最近错误描述

3.1.3. OKJSON.stringToObject

方法原型 T stringToObject( String jsonString, Class clazz, int options );
方法说明 映射JSON字符串中的字段数据到实体类属性
参数 String jsonString : JSON字符串
Class clazz : 实体类类型
int options : 映射选项
返回值 不等于null : 映射成功,得到实体类对象
等于null : 映射失败

映射选项 说明
OKJSON.OPTIONS_DIRECT_ACCESS_PROPERTY_ENABLE 优先直接赋值属性值,否则优先调用setter赋值属性值
OKJSON.OPTIONS_STRICT_POLICY 当JSON字段类型与实体类属性类型不一致,或JSON字段名在实体类属性列表中找不到等警告事件时中断报错,否则忽视

错误码 错误原因说明
OKJSON_ERROR_END_OF_BUFFER 不完整的JSON
OKJSON_ERROR_UNEXPECT 出现不期望的字符
OKJSON_ERROR_EXCEPTION 发生异常
OKJSON_ERROR_INVALID_BYTE 无效字符
OKJSON_ERROR_FIND_FIRST_LEFT_BRACE JSON首个非白字符不是'{'
OKJSON_ERROR_NAME_INVALID JSON的KEY名字非法
OKJSON_ERROR_EXPECT_COLON_AFTER_NAME 在KEY名字后不是':'
OKJSON_ERROR_UNEXPECT_TOKEN_AFTER_LEFT_BRACE 在'{'后非法分词
OKJSON_ERROR_PORPERTY_TYPE_NOT_MATCH_IN_OBJECT 没有JSON字段类型对应的实体类属性类型
OKJSON_ERROR_NAME_NOT_FOUND_IN_OBJECT JSON字段名在实体类属性列表中找不到
OKJSON_ERROR_NEW_OBJECT 创建对象失败

3.1.4. OKJSON.fileToObject

方法原型 T fileToObject( String filePath, Class clazz, int options );
方法说明 映射JSON字符串中的字段数据到实体类属性
参数 String filePath : JSON文件名
Class clazz : 实体类类型
int options : 映射选项
返回值 不等于null : 映射成功,得到实体类对象
等于null : 映射失败

(映射选项和错误码说明同上)

3.1.5. OKJSON.objectToString

方法原型 String objectToString( Object object, int options );
方法说明 映射实体类属性生成JSON字符串
参数 Object object : 实体类
int options : 映射选项
返回值 不等于null : 生成JSON字符串成功
等于null : 生成失败

映射选项 说明
OKJSON.OPTIONS_DIRECT_ACCESS_PROPERTY_ENABLE 优先直接赋值属性值,否则优先调用setter赋值属性值
OKJSON.OPTIONS_PRETTY_FORMAT_ENABLE 以缩进风格生成JSON,否则按紧凑风格

错误码 错误原因说明
OKJSON_ERROR_END_OF_BUFFER 不完整的JSON
OKJSON_ERROR_EXCEPTION 发生异常
OKJSON_ERROR_NEW_OBJECT 创建对象失败

3.1.6. OKJSON.objectToFile

方法原型 int objectToFile( Object object, String filePath, int options );
方法说明 映射实体类属性生成JSON字符串写到文件中
参数 Object object : 实体类
String filePath : JSON文件名
int options : 映射选项
返回值 等于0 : 生成或写文件成功
不等于0 : 生成或写文件失败

(映射选项和错误码说明同上)

3.2. JSON字段类型与实体类属性类型映射表

JSON字段类型 JSON示例 实体类属性类型
字符串 "..." String
整型数字 123 Byte或byte
整型数字 123 Short或short
整型数字 123 Integer或int
整型数字 123 Long或long
浮点数字 123.456 Float或float
浮点数字 123.456 Double或double
布尔值 true/false Boolean或boolean
字符串 "..." LocalDate
字符串 "..." LocalTime
字符串 "..." LocalDateTime
数组 [...] ArrayList
数组 [...] LinkedList
JSON树枝 {...} JAVA对象

如:

public class DemoUserClass {
	String				userName ;
	String				email ;
}

如:

public class DemoUserClass {
	...
	UserExtInfo			userExtInfo ;
	...
}

class UserExtInfo {
	String				gender ;
	int					age ;
	String				address ;
}

如:

public class DemoUserClass {
	...
	LinkedList<BorrowDetail>	borrowDetailList ;
}

class BorrowDetail {
	String				bookName ;
	String				author ;
	@OkJsonDateTimeFormatter(format="yyyy-MM-dd")
	LocalDate			borrowDate ;
	@OkJsonDateTimeFormatter(format="HH:mm:ss")
	LocalTime			borrowTime ;
}

3.3. JSON数组简单元素类型与实体类属性类型映射表

JSON数组简单元素类型 JSON示例 实体类属性类型
字符串 "..." String
整型数字 123 Byte
整型数字 123 Short
整型数字 123 Integer
整型数字 123 Long
浮点数字 123.456 Float
浮点数字 123.456 Double
布尔值 true/false Boolean
字符串 "..." LocalDate
字符串 "..." LocalTime
字符串 "..." LocalDateTime
JSON树枝 {...} JAVA对象

如:

public class DemoUserClass {
	LinkedList<String>			interestGroupList ;
}

4. 性能压测

4.1. 测试环境

CPU : Intel Core i5-7500 3.4GHz 3.4GHz Momey : 16GB OS : WINDOWS 10 JAVA IDE : Eclipse 2018-12

4.2. 测试案例

压测对象:okjson v0.0.8.0、fastjson v1.2.56。

压测JSON解析器性能。JSON文本数据映射到实体类各属性里去,交替各压5轮,每轮100万次。

压测JSON生成器性能。由实体类生成JSON文本,交替各压5轮,每轮200万次。

JSON文件press.json

{
	"str1" : "str1" ,
	"int1" : 1234 ,
	"double1" : 1.234 ,
	"boolean1" : true ,
	
	"press2" : {
		"byte2" : 2 ,
		"short2" : 23 ,
		"long2" : 23456789 ,
		"float2" : 2.345
	}
}

实体类PressDataClass.java

package xyz.calvinwilliams.test_jsonparser;

public class PressDataClass {
	private String			str1 ;
	private int				int1 ;
	private Double			double1 ;
	private boolean			boolean1 ;
	private String			null1 ;
	public PressDataClass2	press2 ;
	
	public String getStr1() {
		return str1;
	}
	public void setStr1(String str1) {
		this.str1 = str1;
	}

	public int getInt1() {
		return int1;
	}
	public void setInt1(int int1) {
		this.int1 = int1;
	}

	public Double getDouble1() {
		return double1;
	}
	public void setDouble1(Double double1) {
		this.double1 = double1;
	}

	public boolean isBoolean1() {
		return boolean1;
	}
	public void setBoolean1(boolean boolean1) {
		this.boolean1 = boolean1;
	}

	public PressDataClass2 getPress2() {
		return press2;
	}
	public void setPress2(PressDataClass2 press2) {
		this.press2 = press2;
	}
	
	public String getNull1() {
		return null1;
	}
	public void setNull1(String null1) {
		this.null1 = null1;
	}
}

实体类PressDataClass2.java

package xyz.calvinwilliams.test_jsonparser;

public class PressDataClass2 {
	private byte		byte2 ;
	private short		short2 ;
	private Long		long2 ;
	private float		float2 ;
	
	public byte getByte2() {
		return byte2;
	}
	public void setByte2(byte byte2) {
		this.byte2 = byte2;
	}
	
	public short getShort2() {
		return short2;
	}
	public void setShort2(short short2) {
		this.short2 = short2;
	}
	
	public Long getLong2() {
		return long2;
	}
	public void setLong2(Long long2) {
		this.long2 = long2;
	}
	
	public float getFloat2() {
		return float2;
	}
	public void setFloat2(float float2) {
		this.float2 = float2;
	}
}

4.3. fastjson压测代码

fastjson解析器压测代码PressFastJsonParser.java

package xyz.calvinwilliams.test_jsonparser;

import java.io.File;
import java.io.FileInputStream;

import com.alibaba.fastjson.*;

public class PressFastJsonParser {

	public static void main(String[] args) {
		
		File file = new File( "press.json" ) ;
		Long fileSize = file.length() ;
		byte[] json = new byte[fileSize.intValue()] ;
		try {
			FileInputStream in = new FileInputStream(file);
			in.read(json);
			in.close();
		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
		String jsonString = new String(json) ;
		
		long l , count = 1000000 ;
		long beginMillisSecondstamp = System.currentTimeMillis() ;
		
		for( l = 0 ; l < count ; l++ ) {
			PressDataClass obj = JSON.parseObject(jsonString, new TypeReference<PressDataClass>() {}) ;
			if( obj == null ) {
				System.out.println( "JSON.stringToObject failed" );
				return;
			}
			else if( l == 0 ){
				System.out.println( "JSON.stringToObject ok" );
				
				System.out.println( "------------------------------ dump PressDataClass" );
				System.out.println( "DataClass.str1["+obj.getStr1()+"]" );
				System.out.println( "PressDataClass.int1["+obj.getInt1()+"]" );
				System.out.println( "PressDataClass.Double1["+obj.getDouble1()+"]" );
				System.out.println( "PressDataClass.boolean1["+obj.isBoolean1()+"]" );
				
				System.out.println( "------------------------------ dump PressDataClass.press2" );
				if( obj.press2 != null ) {
					System.out.println( "PressDataClass.branch2.byte2["+obj.press2.getByte2()+"]" );
					System.out.println( "PressDataClass.branch2.short2["+obj.press2.getShort2()+"]" );
					System.out.println( "PressDataClass.branch2.Long2["+obj.press2.getLong2()+"]" );
					System.out.println( "PressDataClass.branch2.float2["+obj.press2.getFloat2()+"]" );
				}
			}
		}
		
		long endMillisSecondstamp = System.currentTimeMillis() ;
		double elpaseSecond = (endMillisSecondstamp-beginMillisSecondstamp)/1000.0 ;
		System.out.println( "count["+count+"] elapse["+elpaseSecond+"]s" );
		double countPerSecond = count / elpaseSecond ;
		System.out.println( "count per second["+countPerSecond+"]" );
		
		return;
	}
}

fastjson生成器压测代码PressFastJsonGenerator.java

package xyz.calvinwilliams.test_jsonparser;

import java.io.File;
import java.io.FileInputStream;

import com.alibaba.fastjson.*;

public class PressFastJsonGenerator {

	public static void main(String[] args) {
		
		PressDataClass	object = new PressDataClass() ;
		
		object.setStr1("str1");
		object.setInt1(1234);
		object.setDouble1(1.234);
		object.setBoolean1(true);
		object.setNull1(null);
		
		object.press2 = new PressDataClass2() ;
		object.press2.setByte2((byte)2);
		object.press2.setShort2((short)23);
		object.press2.setLong2(23456789L);
		object.press2.setFloat2(2.345f);
		
		System.out.println( "------------------------------ dump PressDataClass" );
		System.out.println( "DataClass.str1["+object.getStr1()+"]" );
		System.out.println( "PressDataClass.int1["+object.getInt1()+"]" );
		System.out.println( "PressDataClass.Double1["+object.getDouble1()+"]" );
		System.out.println( "PressDataClass.boolean1["+object.isBoolean1()+"]" );
		System.out.println( "PressDataClass.null1["+object.getNull1()+"]" );
		
		System.out.println( "------------------------------ dump PressDataClass.press2" );
		if( object.press2 != null ) {
			System.out.println( "PressDataClass.branch2.byte2["+object.press2.getByte2()+"]" );
			System.out.println( "PressDataClass.branch2.short2["+object.press2.getShort2()+"]" );
			System.out.println( "PressDataClass.branch2.Long2["+object.press2.getLong2()+"]" );
			System.out.println( "PressDataClass.branch2.float2["+object.press2.getFloat2()+"]" );
		}
		
		long l , count = 5000000 ;
		long beginMillisSecondstamp = System.currentTimeMillis() ;
		
		for( l = 0 ; l < count ; l++ ) {
			String jsonString = JSON.toJSONString( object ) ;
			if( jsonString == null ) {
				System.out.println( "JSON.toJSONString failed" );
				return;
			}
			else if( l == count-1 ){
				System.out.println( "JSON.toJSONString ok" );
				System.out.println( jsonString );
			}
		}
		
		long endMillisSecondstamp = System.currentTimeMillis() ;
		double elpaseSecond = (endMillisSecondstamp-beginMillisSecondstamp)/1000.0 ;
		System.out.println( "count["+count+"] elapse["+elpaseSecond+"]s" );
		double countPerSecond = count / elpaseSecond ;
		System.out.println( "count per second["+countPerSecond+"]" );
		
		return;
	}
}

4.4. okjson压测代码

okjson解析器压测代码PressOkJsonParser.java

package xyz.calvinwilliams.test_jsonparser;

import java.io.File;
import java.io.FileInputStream;

import xyz.calvinwilliams.okjson.*;
import xyz.calvinwilliams.test_jsonparser.PressDataClass;

public class PressOkJsonParser {

	public static void main(String[] args) {
		
		File file = new File( "press.json" ) ;
		Long fileSize = file.length() ;
		byte[] json = new byte[fileSize.intValue()] ;
		try {
			FileInputStream in = new FileInputStream(file);
			in.read(json);
			in.close();
		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
		String jsonString = new String(json) ;
		
		long l , count = 1000000 ;
		long beginMillisSecondstamp = System.currentTimeMillis() ;
		
		for( l = 0 ; l < count ; l++ ) {
			PressDataClass object = OKJSON.stringToObject( jsonString, PressDataClass.class, OKJSON.OPTIONS_DIRECT_ACCESS_PROPERTY_ENABLE ) ;
			if( object == null ) {
				System.out.println( "okjson.stringToObject failed["+OKJSON.getErrorCode()+"]" );
				return;
			} else if( l == 0 ){
				System.out.println( "okjson.stringToObject ok" );
				
				System.out.println( "------------------------------ dump PressDataClass" );
				System.out.println( "DataClass.str1["+object.getStr1()+"]" );
				System.out.println( "PressDataClass.int1["+object.getInt1()+"]" );
				System.out.println( "PressDataClass.Double1["+object.getDouble1()+"]" );
				System.out.println( "PressDataClass.boolean1["+object.isBoolean1()+"]" );
				
				System.out.println( "------------------------------ dump PressDataClass.press2" );
				if( object.press2 != null ) {
					System.out.println( "PressDataClass.branch2.byte2["+object.press2.getByte2()+"]" );
					System.out.println( "PressDataClass.branch2.short2["+object.press2.getShort2()+"]" );
					System.out.println( "PressDataClass.branch2.Long2["+object.press2.getLong2()+"]" );
					System.out.println( "PressDataClass.branch2.float2["+object.press2.getFloat2()+"]" );
				}
			}
		}
		
		long endMillisSecondstamp = System.currentTimeMillis() ;
		double elpaseSecond = (endMillisSecondstamp-beginMillisSecondstamp)/1000.0 ;
		System.out.println( "count["+count+"] elapse["+elpaseSecond+"]s" );
		double countPerSecond = count / elpaseSecond ;
		System.out.println( "count per second["+countPerSecond+"]" );
		
		return;
	}
}

okjson生成器压测代码PressOkJsonGenerator.java

package xyz.calvinwilliams.test_jsonparser;

import java.io.File;
import java.io.FileInputStream;

import xyz.calvinwilliams.okjson.OKJSON;
import xyz.calvinwilliams.test_jsonparser.PressDataClass;

public class PressOkJsonGenerator {

	public static void main(String[] args) {
		
		PressDataClass	object = new PressDataClass() ;
		
		object.setStr1("str1");
		object.setInt1(1234);
		object.setDouble1(1.234);
		object.setBoolean1(true);
		object.setNull1(null);
		
		object.press2 = new PressDataClass2() ;
		object.press2.setByte2((byte)2);
		object.press2.setShort2((short)23);
		object.press2.setLong2(23456789L);
		object.press2.setFloat2(2.345f);
		
		System.out.println( "------------------------------ dump PressDataClass" );
		System.out.println( "DataClass.str1["+object.getStr1()+"]" );
		System.out.println( "PressDataClass.int1["+object.getInt1()+"]" );
		System.out.println( "PressDataClass.Double1["+object.getDouble1()+"]" );
		System.out.println( "PressDataClass.boolean1["+object.isBoolean1()+"]" );
		System.out.println( "PressDataClass.null1["+object.getNull1()+"]" );
		
		System.out.println( "------------------------------ dump PressDataClass.press2" );
		if( object.press2 != null ) {
			System.out.println( "PressDataClass.branch2.byte2["+object.press2.getByte2()+"]" );
			System.out.println( "PressDataClass.branch2.short2["+object.press2.getShort2()+"]" );
			System.out.println( "PressDataClass.branch2.Long2["+object.press2.getLong2()+"]" );
			System.out.println( "PressDataClass.branch2.float2["+object.press2.getFloat2()+"]" );
		}
		
		long l , count = 5000000 ;
		long beginMillisSecondstamp = System.currentTimeMillis() ;
		
		for( l = 0 ; l < count ; l++ ) {
			String jsonString = OKJSON.objectToString( object, 0 ) ;
			if( jsonString == null ) {
				System.out.println( "okjson.stringToObject failed["+OKJSON.getErrorCode()+"]["+OKJSON.getErrorDesc()+"]" );
				return;
			} else if( l == count-1 ){
				System.out.println( "okjson.stringToObject ok" );
				System.out.println( jsonString );
			}
		}
		
		long endMillisSecondstamp = System.currentTimeMillis() ;
		double elpaseSecond = (endMillisSecondstamp-beginMillisSecondstamp)/1000.0 ;
		System.out.println( "count["+count+"] elapse["+elpaseSecond+"]s" );
		double countPerSecond = count / elpaseSecond ;
		System.out.println( "count per second["+countPerSecond+"]" );
		
		return;
	}
}

4.5. 测试过程

JSON解析器性能

okjson

count[1000000] elapse[1.446]s
count per second[691562.9322268326]

fastjson

count[1000000] elapse[2.616]s
count per second[382262.996941896]

okjson

count[1000000] elapse[1.429]s
count per second[699790.0629811056]

fastjson

count[1000000] elapse[2.547]s
count per second[392618.767177071]

okjson

count[1000000] elapse[1.42]s
count per second[704225.3521126761]

fastjson

count[1000000] elapse[2.473]s
count per second[404367.1653861707]

okjson

count[1000000] elapse[1.432]s
count per second[698324.0223463688]

fastjson

count[1000000] elapse[2.48]s
count per second[403225.8064516129]

okjson

count[1000000] elapse[1.434]s
count per second[697350.069735007]

fastjson

count[1000000] elapse[2.459]s
count per second[406669.37779585196]

JSON生成器性能

okjson

count[2000000] elapse[1.399]s
count per second[1429592.5661186562]

fastjson

count[2000000] elapse[1.51]s
count per second[1324503.311258278]

okjson

count[2000000] elapse[1.347]s
count per second[1484780.9948032666]

fastjson

count[2000000] elapse[1.507]s
count per second[1327140.0132714002]

okjson

count[2000000] elapse[1.364]s
count per second[1466275.6598240468]

fastjson

count[2000000] elapse[1.403]s
count per second[1425516.7498218103]

okjson

count[2000000] elapse[1.363]s
count per second[1467351.4306676448]

fastjson

count[2000000] elapse[1.512]s
count per second[1322751.3227513228]

okjson

count[2000000] elapse[1.37]s
count per second[1459854.01459854]

fastjson

count[2000000] elapse[1.409]s
count per second[1419446.4158978]

4.6. 测试结果

JSON解析器性能曲线图:

json_parsers_benchmark.png

JSON生成器性能曲线图:

json_generators_benchmark.png

说明:

  • 在JSON解析/反序列化处理性能上,okjson比fastjson快了近一倍(75%)。
  • 在JSON生成/序列化处理性能上,okjson比fastjson快了少许(7%)

其它说明:

  • fastjson静态类名为JSON取名不好,容易和其它JSON库冲突,或许温少就是这么霸气。okjson静态类名为OKJSON,比较低调 :)
  • 实体类中加了很多setter和getter是为了fastjson,okjson并不需要。okjson甚至连实体类构造方法都没有要求必须有,作为通用框架要兼容各种各样的场景。

5. 后续开发

  • 支持更多字段类型,如老版本JAVA的日期、时间类。
  • 增加XML解析器、生成器功能。

6. 关于本项目

欢迎使用okjson,如果你在使用中碰到了问题请告诉我,谢谢 ^_^

源码托管地址 : 开源中国github

Apache Maven

<dependency>
  <groupId>xyz.calvinwilliams</groupId>
  <artifactId>okjson</artifactId>
  <version>0.0.9.0</version>
</dependency>

Gradle Kotlin DSL

compile("xyz.calvinwilliams:okjson:0.0.9.0")

7. 关于作者

厉华,左手C,右手JAVA,写过小到性能卓越方便快捷的日志库、HTTP解析器、日志采集器等,大到交易平台/中间件等,分布式系统实践者,容器技术专研者,目前在某城商行负责基础架构。

通过邮箱联系我 : 网易Gmail

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} 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.

简介

JAVA编写的小巧、高效、灵活的JSON处理器(JSON解析器+JSON生成器) 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/yjn/okjson.git
git@gitee.com:yjn/okjson.git
yjn
okjson
okjson
deve

搜索帮助