Skip to content

Latest commit

 

History

History
116 lines (80 loc) · 3.8 KB

README-en.md

File metadata and controls

116 lines (80 loc) · 3.8 KB

Lson

A Java library for JSON serialization/deserialization, it has good performance and high extensibility.

Build Status GitHub release Maven Central License Language

中文   |   English

Features

  • Easy to get started, quick to use with installation
  • Intuitive, convenient, and easy to use serialization/deserialization process based on annotations and JSONPath
  • Support for deserializing complex entity classes and variables
  • Good support for generics
  • Continuously updated built-in annotations for easy data processing
  • Customizable annotations to extend Lson's functionality

Download

Gradle

implementation 'cn.luern0313.lson:Lson:0.90'

Maven

<dependency>
    <groupId>cn.luern0313.lson</groupId>
    <artifactId>Lson</artifactId>
    <version>0.90</version>
</dependency>

Getting Started

JSON Parsing

LsonElement lsonElement = LsonUtil.parse(jsonString);

This method returns a LsonElement. If you are sure that the JSON is an Object or Array, you can also use:

LsonObject lsonObject = LsonUtil.parseAsObject(jsonString);

or

LsonArray lsonArray = LsonUtil.parseAsArray(jsonString);

JSON Deserialization

XXXModel model = LsonUtil.fromJson(lsonElement, XXXModel.class);

You need an entity class for Lson to deserialize, and you need to add the @LsonPath annotation to the variables you want to deserialize and fill in the path to describe the location of this variable in the JSON. You can also use Lson's built-in annotations or custom annotations to handle variables in deserialization. For more detailed usage, see the Lson Wiki

JSON Serialization

String json = LsonUtil.toJson(model);

Again, the @LsonPath annotation is also needed for Lson to locate the value in a specific location in the json. Built-in and custom annotations can also be used for serialization. For more detailed usage, see the Lson Wiki

Contribute to this project

You are welcome to grow with this project! To contribute your code, please Fork and Pull Requests. Or raise an Issue to report problems or suggestions.

Developers

luern0313

Special thanks to: lzjyzq2setTile group

Contact me

Bilibili: https://space.bilibili.com/8014831
Github: https://github.com/luern0313
Personal website: https://luern0313.cn

License

Lson uses theApache 2.0 license

Copyright 2020 luern0313

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.