Errors & Debugging
Understanding JSSON's friendly error messages and how to debug common issues. Meet the goblins, wizards, and gremlins!
JSSON has a unique approach to errors β instead of cryptic messages, you get help from friendly (well, mostly friendly) creatures! π§ββοΈπΊ
The Error Squad
JSSON's error system has three characters, each responsible for a different phase:
| Character | Phase | What They Check |
|---|---|---|
| Lex Goblin πΊ | Lexing | Invalid characters, unterminated strings |
| Parse Wizard π§ββοΈ | Parsing | Syntax errors, unexpected tokens |
| Transpiler Gremlin πΉ | Transpilation | Type errors, undefined references |
Lex Goblin Errors πΊ
The Lex Goblin catches errors during tokenization β when JSSON reads your file character by character.
Illegal Character
Error:
Lex goblin: 1:5 β Illegal character: '@'What it means: You used a character that JSSON doesn't recognize.
Example:
name = JoΓ£o@Silva // β @ is not allowed without quotesFix:
name = "JoΓ£o@Silva" // β
Use quotes for special charactersUnterminated String
Error:
Lex goblin: 2:10 β Unterminated stringWhat it means: You started a string with " but never closed it.
Example:
name = "JoΓ£o
age = 25 // β Missing closing quoteFix:
name = "JoΓ£o" // β
Close the string
age = 25Parse Wizard Errors π§ββοΈ
The Parse Wizard catches syntax errors β when your JSSON structure is invalid.
Unexpected Token
Error:
Parse wizard: 3:8 β Unexpected token: expected '=', got '{'What it means: The parser expected one thing but found another.
Example:
user
{ // β Missing assignment operator
name = JoΓ£o
}Fix:
user { // β
Add the assignment (or just put { on same line)
name = JoΓ£o
}Missing Closing Brace
Error:
Parse wizard: EOF β Expected '}', got EOFWhat it means: You opened a { but never closed it.
Example:
user {
name = JoΓ£o
age = 25
// β Missing }Fix:
user {
name = JoΓ£o
age = 25
} // β
Close the objectInvalid Array Syntax
Error:
Parse wizard: 2:15 β Expected ']', got ','What it means: Array syntax is incorrect.
Example:
colors = [ red, blue, green,, ] // β Double commaFix:
colors = [ red, blue, green ] // β
Remove extra commaTemplate Errors
Error:
Parse wizard: 3:5 β Template expects 3 fields, got 2What it means: A template row doesn't match the template definition.
Example:
users [
template { name, age, email }
JoΓ£o, 25 // β Missing email
]Fix:
users [
template { name, age, email }
JoΓ£o, 25, "joao@test.com" // β
All 3 fields
]Transpiler Gremlin Errors πΉ
The Transpiler Gremlin catches semantic errors β when your JSSON is syntactically correct but logically wrong.
Undefined Reference
Error:
Transpiler gremlin: 5:12 β Undefined reference: 'config.port'What it means: You're trying to access a property that doesn't exist.
Example:
server {
host = localhost
}
url = server.host + ":" + config.port // β config doesn't existFix:
server {
host = localhost
port = 8080 // β
Define port
}
url = server.host + ":" + server.port // β
Use server.portType Mismatch
Error:
Transpiler gremlin: 3:10 β Cannot perform operation '+' on boolean and stringWhat it means: You're trying to combine incompatible types.
Example:
active = true
message = "Status: " + active // β Can't add boolean to stringFix:
active = "true" // β
Make it a string
message = "Status: " + activeCommon Mistakes & Solutions
1. Forgetting Quotes
Problem:
title = Software Engineer // β Space without quotesSolution:
title = "Software Engineer" // β
Use quotes for spaces2. Using JSON Syntax
Problem:
user {
"name": "JoΓ£o", // β JSON syntax
"age": 25,
}Solution:
user {
name = JoΓ£o // β
JSSON syntax
age = 25
}3. Missing Commas in Arrays
Problem:
colors = [ red blue green ] // β Missing commasSolution:
colors = [ red, blue, green ] // β
Add commas4. Trailing Commas
Problem:
colors = [ red, blue, green, ] // β Trailing commaSolution:
colors = [ red, blue, green ] // β
Remove trailing comma5. Wrong File Extension
Problem:
jsson -i config.json # β Wrong extensionSolution:
jsson -i config.jsson # β
Use .jsson extensionDebugging Tips
1. Check Line Numbers
Error messages always include line and column numbers:
Parse wizard: 15:8 β Unexpected token
β β
line columnGo to that exact location in your file!
2. Look for Unclosed Brackets
If you see EOF (End Of File) errors, you probably forgot to close something:
user {
name = JoΓ£o
config {
theme = dark
// β Missing } for config
// β Missing } for userTip: Use an editor with bracket matching!
3. Validate Incrementally
Build your JSSON file step by step:
# Start simple
echo 'name = JoΓ£o' > test.jsson
jsson -i test.jsson # β
Works
# Add more
echo 'age = 25' >> test.jsson
jsson -i test.jsson # β
Still works
# Keep adding until you find the problem4. Use Comments to Debug
Comment out sections to isolate the problem:
user {
name = JoΓ£o
age = 25
}
// database {
// host = localhost
// port = 5432
// }
api {
url = "https://api.example.com"
}5. Check Your Quotes
Mixed quotes can cause issues:
name = "JoΓ£o' // β Mismatched quotes
name = "JoΓ£o" // β
Matching quotesError Message Format
All JSSON errors follow this format:
[Character]: [Location] β [Message]Example:
Lex goblin: config.jsson:15:8 β Illegal character: '@'
β β β
Character Location MessageLocation formats:
15:8β Line 15, column 8config.jsson:15:8β File, line, columnEOFβ End of file
Getting Help
If you're stuck:
- Read the error message carefully β it usually tells you exactly what's wrong
- Check the line number β go to that exact location
- Look at examples in the Syntax Reference
- Compare with working code β what's different?
- Ask for help on GitHub Issues
What's Next?
Now that you know how to debug JSSON:
- Syntax Reference β Complete syntax guide
- Templates Guide β Master template arrays
- CLI Guide β Command-line options
Don't fear the errors β the goblins, wizards, and gremlins are here to help! π§ββοΈπΊπΉ