JSON Practice: Fix a Broken Configuration File
Configuration files are often edited by hand, and a single wrong character can stop an application from starting. JSON is strict, so validators report the exact place of the problem. This exercise has three different mistakes to find and repair one at a time.
Before you start: Objects, arrays, strings, numbers and booleans.
Your task
Make this configuration valid JSON. Remove the comment, replace the Python-style True with a JSON boolean and add the missing comma between the two hosts.
Starter code
{
// server settings
"port": 8080,
"debug": True,
"hosts": ["localhost" "example.com"]
}
Expected result
Valid JSON with port 8080, debug true and two hosts.Loads the starter in the workspace. Save or export existing work first. Return here for hints and the explanation.
Need a hint?
Look for a line that starts with two slashes, a value spelled True, and two array items with no comma between them.
Show the complete solution and walkthrough
{
"port": 8080,
"debug": true,
"hosts": ["localhost", "example.com"]
}
- Delete the comment line. Standard JSON has no comment syntax, even though some tools accept JSONC or JSON5.
- Change True to true. JSON booleans are always lowercase, and they are written without quotation marks.
- Add a comma between "localhost" and "example.com". Run the validator again to confirm that the document is now valid.
A common mistake
Putting quotation marks around true turns the boolean into a string. Fixing several errors at once makes it hard to see which change solved which problem.
Try an edge case
A valid document can still be wrong for your application. JSON validation checks syntax, not whether port is in a sensible range or hosts contains real names.
Take it one step further
Add a nested "limits" object with timeout and retries properties. Then introduce a deliberate trailing comma and read the validator message.