Package org.nustaq.kson
Class Kson
java.lang.Object
org.nustaq.kson.Kson
a simple text <=> object serialization. More readable than JSon, less complication/error prone than Yaml.
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));
}
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassfumbleOutGenericKeyType(Field field) static ClassfumbleOutGenericValueType(Field field) booleanstatic voidmap to simple namereadObject(File file) readObject(File file, Class type) readObject(File file, String type) readObject(InputStream stream, String encoding, String expectedType) readObject(String dson) readObject(String dsonOrJSon, String expectedType) readObject(String dsonOrJSon, String expectedType, KsonArgTypesResolver resolve) supportJSon(boolean supportJSon) writeJSonObject(Object o, boolean tagTopLevel) writeObject(Object o, boolean tagTopLevel)
-
Field Details
-
conf
-
-
Constructor Details
-
Kson
-
Kson
public Kson()
-
-
Method Details
-
fumbleOutGenericKeyType
-
fumbleOutGenericValueType
-
map
-
map
map to simple name- Parameters:
c-- Returns:
-
readObject
- Throws:
Exception
-
readObject
public Object readObject(String dsonOrJSon, String expectedType, KsonArgTypesResolver resolve) throws Exception - Throws:
Exception
-
readObject
- Throws:
Exception
-
isSupportJSon
public boolean isSupportJSon() -
supportJSon
-
readObject
- Throws:
Exception
-
readObject
- Throws:
Exception
-
readObject
- Throws:
Exception
-
readObject
- Throws:
Exception
-
writeObject
- Throws:
Exception
-
writeObject
- Throws:
Exception
-
writeJSonObject
- Throws:
Exception
-
writePlainJSonObject
- Throws:
Exception
-
getMapper
-
main
- Throws:
Exception
-