Class RandomJson
java.lang.Object
ca.marcusdunn.jsonlens.testkit.RandomJson
Makes random JSON texts (RFC 8259) from a seed. The same seed gives the same texts.
The texts have the cases that models often get wrong: escapes, non-ASCII characters and
surrogate pairs, the empty name, numbers with an exponent or a fraction, integers larger than a
long, equal numbers in different forms such as 100 and 1E+2, and empty and nested
containers. The member names of each object are unique.
RandomJson random = RandomJson.withSeed(42); // The same seed gives the same documents.
for (int i = 0; i < 100; i++) {
Object document = parse(random.next());
assertEquals(List.of(), verifier.verify(document));
}
-
Method Summary
Modifier and TypeMethodDescriptionnext()Makes the next JSON text.static RandomJsonwithSeed(long seed) Returns a generator with a seed.
-
Method Details
-
withSeed
Returns a generator with a seed.- Parameters:
seed- the seed- Returns:
- a new generator
-
next
Makes the next JSON text. Its root is an object or an array.- Returns:
- a JSON text
-