jsonut 0.3.0
jsonut: ^0.3.0 copied to clipboard
A minimal utility kit for working with JSON in a typesafe manner.
0.3.0 #
-
Breaking change: Removed
JsonAny.tryFrom, which was at best, confusing as it accepted a nullable value and returned a nullable value. Either useJsonAny.fromoras JsonAny. -
Breaking change:
<JsonAny>.as<T>()no longer is bound toJsonValue. This avoids cases where the type would be inferred asNeverbecause it was something likeint, which should be fine. -
Added
<JsonObject>.deepGetto get nested values:final object = JsonObject.parse('{"name": {"first": "John", "last": "Doe"}}'); final firstName = object.deepGet(['name', 'first']).string(); -
Improved some error messages.
0.2.1 #
- Fixed a bug where
JsonArray's elements wereJsonValuenotJsonAny.
0.2.0 #
-
Added
.asand.asOrNullmethods toJsonAnyfor inference casting:final class Employee { const Employee({required this.name}); final String name; } final object = JsonObject.parse('{"name": "John Doe"}'); final employee = Employee(name: object['name'].as()); -
Breaking change:
<JsonAny>.{type}Orrenamed to<JsonAny>.{type}OrNullto better reflect the behavior of the method, and be idiomatic with other Dart APIs:- print(any.stringOr('name')); + print(any.stringOrNull('name')); -
Breaking change:
<JsonType>.parseonly throws aFormatExceptionif the input is not valid JSON, and anArgumentErrorif the input is not the expected type. This makes the behavior more consistent with other Dart APIs. -
Breaking change: Reduced the API of
JsonObjectto remove.{type}()methods in favor of just providing a custom[]operator tht returnsJsonAnyinstances.- print(person.string('name')); + print(person['name'].string());Saving roughly ~2 characters per call wasn't worth the additional complexity.
0.1.0 #
- Initial development release.