Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 1.83 KB

README.md

File metadata and controls

66 lines (46 loc) · 1.83 KB

LiteJavaJson

Build Status Code Quality License

The purpose of this project is to provide a very simple, no-fluff, single source file Java JSON Serializer/Deserializer.

This project is designed to offer maximum value with minimal setup/configuration/learning. It is designed to make Object mapping simple and painless.

The code is written in a procedural Utility-class style.

Usage

Add to Project

This library contains a single source file: Json.java

Copy-paste this file directly into your project.

Serialization

// Sample class
public class SimpleStringValueObject
{
    public String Value;
}

SimpleStringValueObject obj = new SimpleStringValueObject();
obj.Value = "Important Data Here";
String jsonString = Json.toJsonString(obj); 
// jsonString: { "Value": "Important Data Here" }

Deserialization

// Sample class
public class SimpleStringValueObject
{
    public String Value;
}

SimpleStringValueObject obj = Json.toObj(
	    SimpleStringValueObject.class, 
	    "{ \"Value\": \"Important Data Here\" }");

Deserialize Single Element Value (no Java object required)

double price = Json.getElementValue(
        Double.class, 
        "Price", 
		"{ \"Data1\": \"Something Useless\", \"Price\": 2.57 }");

Credits

Silas Reinagel

License

You may use this code in part or in full however you wish.
No credit or attachments are required.