FastPrepFlatten a Nested Object Into Dot Keys
Problems/Flatten a Nested Object Into Dot Keys

Flatten a Nested Object Into Dot Keys

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem asks for every plain value inside an object of objects, listed with the chain of keys that leads to it, joined by dots. Its source, a frontend engineer's account of a first round on JavaScript fundamentals, names that conversion as one of the coding tasks but gives no input form, value types, ordering or examples.

Our choices: the object arrives as compact text with unquoted keys (so every language can read it), values are objects, integers, true, false or null, values are copied as written, empty objects produce nothing, results keep the left-to-right order of the text, the text is at most 5000 characters with at most 50 levels, and the examples are new. Arrays are left out.

The judged task matches the report at about 60%.

You get a nested object written as text in a compact, JSON-like format:

  • An object is {, then zero or more key:value pairs separated by commas, then }. Keys are not quoted.
  • A value is another object, an integer, or one of the words true, false and null.

Flatten it. For every value that is not an object, output one string path=value:

  • path is the chain of keys from the outer object down to this value, joined with dots, for example user.tags.admin.
  • value is written exactly as it appears in text.
  • An empty object {} holds no values, so it produces nothing.

Return the strings in the order their values appear in text, from left to right.

Function

flattenObject(text: String) → String[]

Examples

Example 1

text = "{user:{name:7,tags:{admin:true,beta:false}},id:42}"return = ["user.name=7","user.tags.admin=true","user.tags.beta=false","id=42"]

Walk the object in order. user holds an object, so its keys get the prefix user.; tags inside it adds user.tags.. The top-level id has no prefix.

Example 2

text = "{a:{},b:null,c:{d:{}}}"return = ["b=null"]

Empty objects hold no values, so a and c.d produce nothing. null is a value and is kept as written.

Example 3

text = "{}"return = []

An empty object has nothing to list.

Constraints

  • 2 <= text.length <= 5000
  • text is one valid object in the format above, with no spaces.
  • Each key is 1 to 10 lowercase letters or digits, and keys inside one object are all different.
  • Each integer is written without leading zeros (a lone 0 is fine, -0 is not) and is between -10^9 and 10^9.
  • Objects are nested at most 50 levels deep, counting the outer object.

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public String[] flattenObject(String text) {
    // Write your code here.
}
Checking account…