Disclosure. JSON2Class is our own project. This guide uses its JSONPath tester to examine a narrow extraction workflow. It also documents unsupported syntax so a successful example is not mistaken for complete standards support. The order records are synthetic fixtures.
A large API response often contains a small piece of information you actually need: every order identifier, each line-item SKU, or a single nested vendor field. Manually copying those values is fragile, especially when the response has several array levels. A reusable expression is easier to review, provided you understand how the chosen implementation handles arrays, missing members and unsupported operators.
This article is about selecting existing values. It does not validate the entire response, change the document or generate application models. Keeping that scope explicit helps you pick the correct next tool rather than expecting one expression to solve every payload problem.
Begin with a small representative document
Open the JSON2Class JSONPath Tester and paste a redacted document containing the shape you want to query. Start with a small subtree when the original response is very large. This makes it easier to distinguish a wrong path from a result that is simply buried in a long list.
The lab document contains two orders, nested line items and a literal dotted property name:
{
"orders": [
{
"id": "A",
"items": [
{
"sku": "PEN",
"quantity": 2
},
{
"sku": "BOOK",
"quantity": 1
}
]
},
{
"id": "B",
"items": [
{
"sku": "BAG",
"quantity": 1
}
]
}
],
"vendor.code": "DEMO"
}
Order A contains two items and order B contains one. That difference is intentional. An extraction exercise with exactly one element at each level can accidentally make an incorrect path look sufficient. The dotted vendor key is another discriminating case: punctuation inside a literal property name must not be confused with navigation between objects.
Record what the input represents, where you expect the array boundaries to be and what a matching result should look like. An expression without an expected result is easy to accept merely because it returned something. That is a weak test for a reporting or transformation workflow.
Follow the array boundaries explicitly
For the two order identifiers, the tested expression was $.orders[*].id. The wildcard visits each element of the orders array before selecting id. The recorded result is:
[
"A",
"B"
]
For the nested item SKUs, the expression was $.orders[*].items[*].sku. It needs a wildcard at both collection levels. The recorded result is:
[
"PEN",
"BOOK",
"BAG"
]
The result is a list of matched values. It is not a reconstructed order document and it does not carry the parent order identifier beside every SKU. If the downstream task needs both values together, keep that relationship in a separate transformation rather than assuming the flattened selection preserved it automatically.
That distinction is important when debugging repeated values. Two orders can contain the same SKU. A list of SKUs can show both matches while providing no explanation of which parent record produced them. Never treat that flattened list as a unique entity index unless the contract and the transformation explicitly establish uniqueness.
Use indexes only when position is meaningful
The expression $.orders[-1].id returned B in the source-snapshot lab. The negative index selects relative to the end of the array in this implementation. It does not mean the most recently created order unless the API guarantees the relevant ordering.
Similarly, $.orders[0:1].id returned A. The slice selects a positional range; it is not a condition on the order's business identity. Use an index or slice for a positional requirement, and record the ordering assumption alongside the query so it remains visible during later maintenance.
To see why this matters, imagine that the provider changes its default ordering from creation time to identifier. A positional expression may still return a valid string but now select a different business record. A syntax check would pass while the consumer's intent failed. Expected-value fixtures should therefore include the ordering scenario as well as the document shape.
The JSONPath standard defines a broader query language and result model. A browser utility implementing useful operators does not automatically implement every standardized feature. Verify the exact syntax your workflow depends on in the selected tool, instead of transferring an expression from another library without testing it.
Quote literal property names containing punctuation
The fixture includes a member literally named vendor.code. The tested bracket expression $['vendor.code'] returned DEMO. A dotted expression would try to navigate through an object named vendor to a child named code, which is a different structure.
This is a common source of empty results in configuration payloads and flattened exports. Read the actual property name before interpreting a dot as an object boundary. Preserve the original JSON so another reviewer can see whether the punctuation belongs to the member name or to your query syntax.
Do not interchange JSONPath, the readable labels in a JSON Diff result and JSON Pointer paths used by JSON Patch. They solve different addressing problems and have different notation. The JSON Diff review guide explains why a displayed dotted diff label can itself be ambiguous.
Treat an empty result as a question, not an approval
The lab queried $.orders[*].missing and obtained an empty list. That means no matching values were selected from this fixture. It does not prove that the response is valid, that every order should omit the field, or that the provider removed it intentionally.
Check the expected location, spelling, case and array shape before concluding that a field is absent. Then decide whether absence should be acceptable for the consumer. If a required identifier is missing, an empty query result may be a validation failure for your application even though the extraction utility completed normally.
Build separate fixtures for an absent member, an explicit null and an empty array. These states can require different application behavior. For instance, a reporting pipeline might need to distinguish no matching orders from matched orders whose optional fields contain null. A list of extracted values is only one piece of that decision.
Filters are not supported by the tested implementation
The lab tried $.orders[?(@.id == "A")]. The parser rejected this filter expression. The guide does not replace that rejection with a made-up result or suggest a special setting that the utility does not provide.
When a path copied from another tool uses a filter, verify whether the current tester accepts it before building documentation around it. A supported wildcard is not evidence that arbitrary predicate expressions are supported. The same caution applies to extensions, function calls and edge-case escaping rules you have not exercised.
If your task requires conditional selection, use a library or transformation stage that supports that requirement and test it there. You can still use this browser utility to inspect the nested structure and validate supported positional expressions. Keep the boundary visible: exploration in one tool does not demonstrate production-library conformance in another.
Reproduce, then turn the query into a workflow fixture
The article's source-snapshot assertions can be executed from the blog repository:
node examples/json2class-seo-lab/run.mjs
They cover both wildcard levels, the negative index, the slice, a quoted dotted key, the missing-field result and the rejected filter. The lab README distinguishes repository-source snapshots from the deployed helper used for other examples. These checks do not claim a full browser test or a complete JSONPath conformance suite.
For a durable workflow, save a small redacted input and the expected selection next to the expression. Review changes to those fixtures when the provider changes its response. Test against the actual implementation used by your application before treating a browser result as production evidence.
Try the JSONPath Tester to explore the fixture. If the selected subtree needs a validation contract, continue with the sample-to-schema review guide. If you need to edit the document, read the JSON Patch configuration guide. Browse the JSON2Class developer tools for the corresponding utilities without conflating extraction, validation and mutation.
