Sign inSign up free

1447. Merge Layered JSON Config

medium 20 XP ~12 minHands-on lab

Every service has base.json and an override per environment (prod.json). Write /home/student/config/merge.py:

python3 merge.py BASE OVERRIDE

Task

Print the merged config as JSON with indent=2 and sorted keys, following these rules:

  • Keys only in one file are kept.
  • When both files have an object for a key, merge those objects the same way, at every depth.
  • Anything else in the override (a number, a string, a list) replaces the base value. Lists are not combined.
  • A value of null in the override removes that key from the result.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of Python for DevOps. Next step: Detect Configuration Drift Between Two Environments

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.