← 返回 netflix 的题目列表JSON Path Query on Map<String, Object> with Wildcard (*)
类型:online_judge
Given a JSON object represented as nested Map<String, Object> (no string parsing required), implement a jq-like path query.
Input
json: Map<String,Object> where values can be scalars or nested maps
path: String dot-separated keys, may start with a leading dot
Output
Return the value at the path; if not found return null.
Path rules
Regular keys: .contacts.cell.
Support wildcard * to match any key at the current level.
.*.cell: iterate all top-level keys and continue searching for cell.
If * is the last segment (e.g., contacts.*), return all key/value pairs under that object (e.g., as a Map).
If wildcard produces multiple matches, return a collection (e.g., List<Object>). If there are no matches, return null.
Example
See Chinese section.
Constraints
Total nodes N <= 1e5
Path length K <= 100
Example
Input
json={fname:A, contacts:{cell:111, home:222}}
path=.contacts.cell
Output
111