Package squidpony.store.json
Class JsonCompressor
java.lang.Object
com.badlogic.gdx.utils.Json
squidpony.store.json.JsonCompressor
- Direct Known Subclasses:
DataCompressor
public class JsonCompressor extends com.badlogic.gdx.utils.Json
A variant of
Augmented version of LibGDX's Json class that knows how to handle various data types common in SquidLib. This includes OrderedMap, which notably allows non-String keys (LibGDX's default Map serializer requires keys to be Strings), but does not currently allow the IHasher to be set (which only should affect OrderedMaps with array keys). It also makes significantly shorter serialized output for 2D char arrays, GreasedRegion and FakeLanguageGen objects, and various collections (IntDoubleOrderedMap, IntVLA, Arrangement, K2, and K2V1 at least). Created by Tommy Ettinger on 1/9/2017.
JsonConverter
(and an extension of libGDX's Json
class) that
compresses its JSON output and reads compressed input. Due to limits on the String compression library this uses
(namely, it only compresses Strings, so input must be able to be interpreted as a String), this only allows String
and FileHandle input formats, and throws exceptions if you try to deserialize a char array, InputStream, or Reader
with fromJson() . Otherwise, it acts like JsonConverter, so the same docs apply:
Augmented version of LibGDX's Json class that knows how to handle various data types common in SquidLib. This includes OrderedMap, which notably allows non-String keys (LibGDX's default Map serializer requires keys to be Strings), but does not currently allow the IHasher to be set (which only should affect OrderedMaps with array keys). It also makes significantly shorter serialized output for 2D char arrays, GreasedRegion and FakeLanguageGen objects, and various collections (IntDoubleOrderedMap, IntVLA, Arrangement, K2, and K2V1 at least). Created by Tommy Ettinger on 1/9/2017.
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description JsonCompressor()
JsonCompressor(com.badlogic.gdx.utils.JsonWriter.OutputType outputType)
-
Method Summary
Modifier and Type Method Description <T> T
fromJson(Class<T> type, char[] data, int offset, int length)
<T> T
fromJson(Class<T> type, com.badlogic.gdx.files.FileHandle file)
<T> T
fromJson(Class<T> type, InputStream input)
<T> T
fromJson(Class<T> type, Reader reader)
<T> T
fromJson(Class<T> type, Class elementType, char[] data, int offset, int length)
<T> T
fromJson(Class<T> type, Class elementType, com.badlogic.gdx.files.FileHandle file)
<T> T
fromJson(Class<T> type, Class elementType, InputStream input)
<T> T
fromJson(Class<T> type, Class elementType, Reader reader)
<T> T
fromJson(Class<T> type, Class elementType, String json)
<T> T
fromJson(Class<T> type, String json)
String
toJson(Object object, Class knownType, Class elementType)
void
toJson(Object object, Class knownType, Class elementType, com.badlogic.gdx.files.FileHandle file)
void
toJson(Object object, Class knownType, Class elementType, Writer writer)
Deprecated.Methods inherited from class com.badlogic.gdx.utils.Json
addClassTag, copyFields, getClass, getIgnoreUnknownFields, getSerializer, getTag, getWriter, ignoreUnknownField, newInstance, prettyPrint, prettyPrint, prettyPrint, prettyPrint, prettyPrint, prettyPrint, readField, readField, readField, readField, readField, readFields, readValue, readValue, readValue, readValue, readValue, readValue, readValue, setDefaultSerializer, setDeprecated, setElementType, setEnumNames, setIgnoreDeprecated, setIgnoreUnknownFields, setOutputType, setQuoteLongValues, setReadDeprecated, setSerializer, setSortFields, setTypeName, setUsePrototypes, setWriter, toJson, toJson, toJson, toJson, toJson, toJson, writeArrayEnd, writeArrayStart, writeArrayStart, writeField, writeField, writeField, writeField, writeFields, writeObjectEnd, writeObjectStart, writeObjectStart, writeObjectStart, writeObjectStart, writeType, writeValue, writeValue, writeValue, writeValue, writeValue, writeValue
-
Constructor Details
-
JsonCompressor
public JsonCompressor() -
JsonCompressor
-
-
Method Details
-
toJson
- Overrides:
toJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
object
- The object to serializeknownType
- May be null if the type is unknown.elementType
- May be null if the type is unknown.
-
toJson
public void toJson(Object object, Class knownType, Class elementType, com.badlogic.gdx.files.FileHandle file)- Overrides:
toJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
object
- The object to serializeknownType
- May be null if the type is unknown.elementType
- May be null if the type is unknown.file
- A LibGDX FileHandle that can be written to; overwrites, does not append
-
toJson
Deprecated.Don't use this, please! This method doesn't compress its output.- Overrides:
toJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
object
- The object to serializeknownType
- May be null if the type is unknown.elementType
- May be null if the type is unknown.writer
- A Writer that will be the recipient of this class' JSON output
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.reader
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.elementType
- May be null if the type is unknown.reader
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.input
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.elementType
- May be null if the type is unknown.input
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.file
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.elementType
- May be null if the type is unknown.file
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.data
-offset
-length
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.elementType
- May be null if the type is unknown.data
-offset
-length
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.json
-- Returns:
- May be null.
-
fromJson
- Overrides:
fromJson
in classcom.badlogic.gdx.utils.Json
- Parameters:
type
- May be null if the type is unknown.elementType
-json
-- Returns:
- May be null.
-