squint library
Lightweight JSON processing code generator. Safely deserialize JSON decoded Strings to Dart Types.
Classes
- AbstractType ast
- Main type parent implemented by:
- AnalysisResult
- Result returned after analysing a File analyze.
- ArrayDecodingKeyGenerator decoder
- Generate a key which describes the exact position of a value inside a nested List.
- BooleanType ast
- A Boolean StandardType.
- BracketCounter decoder
- Utility to count brackets and determine which content is inside the same bracket pairs.
- CustomJsonNode
- CustomType ast
- A custom class definition.
- DoubleType ast
- A double StandardType.
-
Either<
T, R> - Either wrapper containing one of T or R.
- EnumType ast
- A custom enumeration definition.
- Float32ListType ast
- A Float32List StandardType.
- Float64ListType ast
- A Float64List StandardType.
- Int32ListType ast
- A Int32List StandardType.
- Int64ListType ast
- A Int64List StandardType.
- IntType ast
- A Integer StandardType.
-
JsonArray<
T> ast decoder encoder - A JSON element containing an Array value.
-
JsonArrayOrNull<
T> ast decoder encoder - A JSON element containing an Array value or null.
- JsonBoolean ast decoder encoder
- A JSON element containing a bool value.
- JsonBooleanOrNull ast decoder encoder
- A JSON element containing a bool value or null.
-
JsonDecode<
T, R> decoder encoder - Decode a JsonNode to a non-standard dart type.
-
JsonEncode<
T> decoder encoder - Encode a (non-standard) dart type to a JsonNode.
- JsonFloatingNumber ast decoder encoder
- A JSON element containing a double value.
- JsonFloatingNumberOrNull ast decoder encoder
- A JSON element containing a double value or null.
- JsonFormattingOptions encoder
- Options to configure JSON formatting.
- JsonIntegerNumber ast decoder encoder
- A JSON element containing an int value.
- JsonIntegerNumberOrNull ast decoder encoder
- A JSON element containing an int value or null.
-
JsonMap<
T> - A JsonObject which children are all of the same type.
-
JsonNode<
T> ast decoder encoder -
A single JSON node representation consisting of
a String key and
T
data. - JsonNull ast decoder encoder
- A JSON element containing a null value.
- JsonObject ast decoder encoder
- JSON Object (Map) element.
- JsonObjectOrNull ast decoder encoder
- JSON Object (Map) element.
- JsonString ast decoder encoder
- A JSON element containing a String value.
- JsonStringOrNull ast decoder encoder
- A JSON element containing a String or null value.
- JsonValue decoder encoder
- Set value of field with value of JsonNode with name.
- ListClosingBracketToken
- Representation of a closing bracket, e.g. '['.
- ListOpeningBracketToken
- Representation of an opening bracket, e.g. '['.
- ListType ast
- A List StandardType.
- ListValueSeparatorToken
- Representation of characters who separate values inside a List, e.g. a comma: ','.
- ListValueToken
- A token representing a character inside a List value.
- MapType ast
- A Map StandardType.
- NullableBooleanType ast
- A nullable Boolean StandardType.
- NullableDoubleType ast
- A nullable double StandardType.
- NullableFloat32ListType ast
- A nullable Float32List StandardType.
- NullableFloat64ListType ast
- A nullable Float64List StandardType.
- NullableInt32ListType ast
- A nullable Int32List StandardType.
- NullableInt64ListType ast
- A nullable Int64List StandardType.
- NullableIntType ast
- A nullable Integer IntType.
- NullableListType ast
- A nullable List StandardType.
- NullableMapType ast
- A nullable Map MapType.
- NullableStringType ast
- A nullable String StandardType.
- NullableUint8ListType ast
- A nullable Uint8List StandardType.
- ObjectOpeningBracketToken
- Representation of a opening squiggly bracket, e.g. '{'.
- SquintGeneratorOptions generator
- Options to configure code generation.
- StandardType ast
- A standard Dart type being one of:
- StringType ast
- A String StandardType.
- TypeAnnotation ast
- Annotation data.
- TypeMember ast
- A class type member (field).
- Uint8ListType ast
- A Uint8List StandardType.
Extensions
- AbstractTypeFromString decoder
- Find matching AbstractType for String value.
- AbstractTypeSerializer analyzer
- CustomType2DataClass generator
- Convert a CustomType to a data class.
- EnumType2EnumClass generator
- Convert a EnumType to an enum class.
- FileAnalyzer analyzer
- FileUtil
- File processing utilities.
- JsonArrayDecoder decoder
- Decode a JSON Array String.
- JsonConversionExtensionsGenerator generator
- Generate JSON (de)serialization methods for a dart class (CustomType).
- JsonDecoder decoder
- Decoded a JSON String as JsonObject.
- JsonFormatter encoder
- Utilities to format a JSON String,
- JsonFormattingOptionsBuilder encoder
- Helper to customize JsonFormattingOptions.
- JsonNodeEnumGenerator generator
- Utilities to generate getters/setters for enum classes and serializers.
- JsonNodeGenerator generator
- Utilities to generate getter/setters for dataclasses and serializers.
- ListDecoder decoder
- Decode a Dart List.
- ListProcessor
- List processing utilities.
- Logger
- Helper for logging.
- MapProcessor
- Map processing utilities.
- RegexValues
- Regex processing utilities.
- RepeatedBuilder decoder
- Utility to construct a nested List structure with strongly typed children.
- SquintGeneratorOptionsBuilder generator
- Builder to customize SquintGeneratorOptions without building an instance from scratch.
- StringUtils
- String processing utilities.
- UnquotedSpaceRemover
- Utility to remove all meaningless spaces from a JSON String.
Constants
- metadataMarkerPrefix → const String analyzer
-
Marker prefix used for metadata debug files.
"sqdb_"
- noAnnotationsGeneratorOptions → const SquintGeneratorOptions generator
-
Generate data class without annotations.
SquintGeneratorOptions(includeJsonAnnotations: false, alwaysAddJsonValue: false, blankLineBetweenFields: false, generateChildClasses: true, includeCustomTypeImports: false)
- squint → const _Squint decoder encoder
-
All classes annotated with @squint will be processed by the squint library.
_Squint()
- standardJsonFormatting → const JsonFormattingOptions encoder
-
Default JSON formatting options.
JsonFormattingOptions(indentation: 4, colonPadding: 1)
-
standardNullableTypes
→ const Map<
String, StandardType> ast -
Map of all standard nullable types.
{"int" : NullableIntType(), "double" : NullableDoubleType(), "bool" : NullableBooleanType(), "String" : NullableStringType(), "Uint8List" : NullableUi…
- standardSquintGeneratorOptions → const SquintGeneratorOptions generator
-
Default code generation options.
SquintGeneratorOptions(includeJsonAnnotations: true, alwaysAddJsonValue: true, blankLineBetweenFields: true, generateChildClasses: true, includeCustomTypeImports: false)
-
standardTypes
→ const Map<
String, StandardType> ast -
Map of all standard types.
{"int" : IntType(), "double" : DoubleType(), "bool" : BooleanType(), "String" : StringType(), "Uint8List" : Uint8ListType(), "Int32List" : I…
Properties
Functions
-
analyze(
{String? pathToFile, String? fileContent, String? pathToOutputFolder, bool overwrite = true}) → AnalysisResult analyzer - The analyzer can read files and return metadata about (dart) classes.
-
buildListStructure<
T> (List< decoderList< positions, {List<int> >T> ? valueList}) → List - Build a nested List which has all required children to set all values.
-
dynamicValue(
{required String key, dynamic data}) → UntypedJsonNode - JSON node of unknown type.
-
getNestedBoolList(
int depth) → List -
Get a List
with 0 or more parent lists. -
getNestedDoubleList(
int depth) → List -
Get a List
with 0 or more parent lists. -
getNestedIntList(
int depth) → List -
Get a List
with 0 or more parent lists. -
getNestedList<
T> ({required int depth, required List< T> valueList}) → List -
Get a List
with 0 or more parent lists. -
getNestedNullableBoolList(
int depth) → List - Get nested List with a nullable bool child. See getNestedBoolList.
-
getNestedNullableDoubleList(
int depth) → List - Get nested List with a nullable double child. See getNestedDoubleList.
-
getNestedNullableIntList(
int depth) → List - Get nested List with a nullable int child. See getNestedIntList.
-
getNestedNullableStringList(
int depth) → List - Get nested List with a nullable String child. See getNestedStringList.
-
getNestedStringList(
int depth) → List -
Get a List
with 0 or more parent lists. -
maybeAddQuotes(
dynamic value) → dynamic encoder - Return a quoted String value for JSON if the current value is a String.
-
toJsonObject(
String json) → JsonObject decoder - Decode a JSON String as JsonObject.
Enums
- JsonIndentationSize encoder
- Length of indentation per level.
Exceptions / Errors
- SquintException
- Exception indicating a problem in the Squint library either internally or by faulty configuration.