Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Validate Nested JSON Configurations

MediumPython00:00
I
Practice interviewer
Your interviewer
In session
I
Interviewer

Welcome to the Python screen.

The question is on your right: Validate Nested JSON Configurations. Read through the requirements first.

Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?

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