Nested Dictionary Path Lookup
Updated
Problem statement
Implement getDictValue(objJson, path) to look up a value in a nested dictionary.
objJson is a string containing a JSON object. path is a nonempty sequence of object keys separated by dots. Starting at the root object, follow each key in order.
- If the next key is absent, return the text
null. - If another key remains but the current value is not a JSON object, return the text
null. Arrays cannot be indexed by the path. - Otherwise, return the value at the completed path as its exact JSON substring from
objJson. Keep string quotes and escapes, number spelling, object member order, and array element order unchanged. An existing JSONnullalso returns the textnull.
The result is always a string containing JSON text. For example, a number returns 5, a string value returns "hello" including its JSON quotes, and an object returns its complete JSON text. Example inputs and outputs use JSON string-literal notation, so their outer quotes encode the argument or result string itself.
Function
getDictValue(objJson: String, path: String) → StringExamples
Example 1
objJson = "{\"car\":{\"wheels\":2,\"gears\":5}}"path = "car.gears"return = "5"The key car leads to an object. Its key gears has value 5, so return the string containing the JSON text 5.
Example 2
objJson = "{\"user\":{\"name\":\"Mia\",\"active\":true},\"count\":2}"path = "user"return = "{\"name\":\"Mia\",\"active\":true}"The only path segment is user. Its complete object value is {"name":"Mia","active":true}, which is returned unchanged.
Example 3
objJson = "{\"car\":{\"wheels\":2}}"path = "car.wheels.size"return = "null"The first two keys reach the number 2. A number is not an object, so it has no next object key size. Return the string containing null.
Constraints
- For this exercise, assume
2 <= objJson.length <= 50000. - For this exercise, assume
1 <= path.length <= 200. - For this exercise, assume
objJsonis valid JSON with an object at its root and no whitespace outside JSON strings. Each object has unique keys; every key is unescaped and matches[a-z][a-z0-9_]*. - For this exercise, assume every path segment matches
[a-z][a-z0-9_]*, with exactly one dot between adjacent segments. - For this exercise, assume at most
100object or array containers are nested at any position, counting the root object.
More Adobe Online Assessment questions
- Base Unit ConversionsOA · Seen Nov 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
Similar questions at other companies
- Polynomial CoefficientsShopify · OAShopify interview questions
- Parse Router LogsIntuit · OAIntuit interview questions
- Simplify a Quadratic ExpressionOpenAI · OAOpenAI interview questions
- DNA Sequence MatchSpaceX · OASpaceX interview questions
- Correct Apartment Bedroom CountsRamp · OARamp interview questions
- Create New VersionCisco · OACisco interview questions
- Order LayoutAmazon · OA
- Validate and Parse HTTP RequestsIBM · OAIBM interview questions
- Convert Backticked Identifiers to Camel CaseZipRecruiter · OAZipRecruiter interview questions
- Simplified XML ValidatorAirbnb · OAAirbnb interview questions
Adobe interview experiences
- Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)