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.
This library contains a single source file: Json.java
Copy-paste this file directly into your project.
// 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" }
// Sample class
public class SimpleStringValueObject
{
public String Value;
}
SimpleStringValueObject obj = Json.toObj(
SimpleStringValueObject.class,
"{ \"Value\": \"Important Data Here\" }");
double price = Json.getElementValue(
Double.class,
"Price",
"{ \"Data1\": \"Something Useless\", \"Price\": 2.57 }");
Silas Reinagel
You may use this code in part or in full however you wish.
No credit or attachments are required.