public class Kson extends Object
Main use is configuration files. - Supports Pojo's only. - No multidimensional or nested arrays. - No untyped Arrays (e.g. Object x[] = new byte[] { 1, 2}) - Collections: Map and List. Use Generics to type collections (can omit type tags then) Example from fast-cast:
public static ClusterConf readFrom( String filePath ) throws Exception {
return (ClusterConf) new Kson()
.map(PublisherConf.class, SubscriberConf.class, TopicConf.class, ClusterConf.class)
.readObject(new File(filePath));
}
| Modifier and Type | Field and Description |
|---|---|
static FSTConfiguration |
conf |
| Constructor and Description |
|---|
Kson() |
Kson(KsonTypeMapper mapper) |
| Modifier and Type | Method and Description |
|---|---|
static Class |
fumbleOutGenericKeyType(Field field) |
static Class |
fumbleOutGenericValueType(Field field) |
KsonTypeMapper |
getMapper() |
boolean |
isSupportJSon() |
Kson |
map(Class... c)
map to simple name
|
Kson |
map(String name,
Class c) |
Object |
readObject(File file) |
Object |
readObject(File file,
Class type) |
Object |
readObject(File file,
String type) |
Object |
readObject(InputStream stream,
String encoding,
String expectedType) |
Object |
readObject(String dson) |
Object |
readObject(String dsonOrJSon,
String expectedType) |
Object |
readObject(String dsonOrJSon,
String expectedType,
KsonArgTypesResolver resolve) |
Kson |
supportJSon(boolean supportJSon) |
String |
writeJSonObject(Object o,
boolean tagTopLevel) |
String |
writeObject(Object o) |
String |
writeObject(Object o,
boolean tagTopLevel) |
String |
writePlainJSonObject(Object o) |
public static FSTConfiguration conf
public Kson(KsonTypeMapper mapper)
public Kson()
public Object readObject(String dsonOrJSon, String expectedType, KsonArgTypesResolver resolve) throws Exception
Exceptionpublic Object readObject(String dsonOrJSon, String expectedType) throws Exception
Exceptionpublic boolean isSupportJSon()
public Kson supportJSon(boolean supportJSon)
public Object readObject(InputStream stream, String encoding, String expectedType) throws Exception
Exceptionpublic String writeObject(Object o, boolean tagTopLevel) throws Exception
Exceptionpublic String writeJSonObject(Object o, boolean tagTopLevel) throws Exception
Exceptionpublic String writePlainJSonObject(Object o) throws Exception
Exceptionpublic KsonTypeMapper getMapper()
Copyright © 2015. All rights reserved.