AssertableJsonString class

A utility class for asserting JSON data in tests.

This class provides methods to validate JSON data structure, content, and perform various assertions on JSON strings or objects.

Example usage:

final json = AssertableJsonString('{"name": "test", "value": 123}'); json .assertCount(2) .assertFragment({'name': 'test'});

Constructors

AssertableJsonString(dynamic jsonable)
Creates a new AssertableJsonString instance.

Properties

decoded Map<String, dynamic>
The decoded JSON data as a Map.
final
hashCode int
The hash code for this object.
no setterinherited
json → dynamic
The original JSON input, which can be either a string or a Map.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

assertCount(int count, [String? key]) AssertableJsonString
Asserts that a JSON object or array has the expected number of elements.
assertExact(Map<String, dynamic> data) AssertableJsonString
Asserts that the JSON matches exactly with the provided data.
assertFragment(Map<String, dynamic> data) AssertableJsonString
Asserts that the JSON contains all the key-value pairs in the provided data.
assertStructure(Map<String, dynamic>? structure, [dynamic responseData]) AssertableJsonString
Asserts that the JSON matches the expected structure.
jsonPath([String? key]) → dynamic
Retrieves a value from the JSON using dot notation path.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited