Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Validate Nested JSON Configurations

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Validate Nested JSON Configurations. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given a JSON string representing a hierarchical model configuration, parse it and validate every nested object. Each node must contain a string field name, a string field type, an object field params, and an optional array field children. Return a list of validation errors using dot-paths such as children[1].params.lr. If the JSON is invalid, return [{"path": "$", "message": "invalid json"}].

Constraints

  • 1 <= len(payload) <= 10^5
  • Maximum nesting depth is at most 10^3
  • Each node contains only valid JSON value types
  • children, when present, must be an array of objects

Function Signature

def validate_model_config(payload):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output