Coder Social home page Coder Social logo

easyfastjson's Introduction

EasyFastJson

Encapsulates Jackon JSON library, Fast Speed Easy Used Json Lib For java

Default Date Format is: yyyy-MM-dd HH:mm:ss Z
example: java.util.Date birth = new java.util.Date();
JSON String out is: 2013-08-16 13:17:03 +0800
Change DateFormat: org.wjw.efjson.JsonObject.setDateFormat(new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));,this change is global!

Two kinds of use:

###1. Standard JSON way:

org.wjw.efjson.JsonObject JSONObjectA = new org.wjw.efjson.JsonObject(JsonString); //create JSON Object

JSONObjectA.putBoolean(String fieldName, Boolean value);
JSONObjectA.putBinary(String fieldName, byte[] binary);
JSONObjectA.putNumber(String fieldName, Number value);
JSONObjectA.putArray(String fieldName, JsonArray value);
JSONObjectA.putString(String fieldName, String value);
JSONObjectA.putObject(String fieldName, JsonObject value);

JSONObjectA.getBoolean(String fieldName);
JSONObjectA.getBinary(String fieldName);
JSONObjectA.getNumber(String fieldName);
JSONObjectA.getArray(String fieldName);
JSONObjectA.getString(String fieldName);
JSONObjectA.getObject(String fieldName);

//no Carriage return and line feed and Indentation Raw Format JSON String
String jsonString = JSONObjectA.encode();

//Prettily Format JSON String
String jsonString = JSONObjectA.encodePrettily();

###2. Like Gson Java Bean way:

//create Java Bean from JSON String
T obj = org.wjw.efjson.JsonObject.fromJson(JsonString,T.class);

//create List from JSON String
List<T> list = JsonObject.fromJson(jsonStr, java.util.List.class, T.class);

//create Map from JSON String
Map<String, T> map = JsonObject.fromJson(jsonStr, java.util.Map.class, String.class, T.class);

//create Complex collection nested types from JSON String
Map<String, List<T>> mmap = JsonObject.fromJson(jsonStr, new TypeReference<Map<String, List<T>>>(){});

//no Carriage return and line feed and Indentation Raw Format JSON String
String jsonString = org.wjw.efjson.JsonObject.toJson(t);

//Prettily Format JSON String
String jsonString = org.wjw.efjson.JsonObject.toJsonPrettily(t);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.