Errors & Debugging
JSSON has a unique approach to errors — instead of cryptic messages, you get help from friendly (well, mostly friendly) creatures! 🧙♂️👺
The Error Squad
Section titled “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 👺
Section titled “Lex Goblin Errors 👺”The Lex Goblin catches errors during tokenization — when JSSON reads your file character by character.
Illegal Character
Section titled “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
Section titled “Unterminated String”Error:
Lex goblin: 2:10 — Unterminated stringWhat it means: You started a string with " but never closed it.
Example:
name = "Joãoage = 25 // ❌ Missing closing quoteFix:
name = "João" // ✅ Close the stringage = 25Parse Wizard Errors 🧙♂️
Section titled “Parse Wizard Errors 🧙♂️”The Parse Wizard catches syntax errors — when your JSSON structure is invalid.
Unexpected Token
Section titled “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 operatorname = João}Fix:
user { // ✅ Add the assignment (or just put { on same line)name = João}Missing Closing Brace
Section titled “Missing Closing Brace”Error:
Parse wizard: EOF — Expected '}', got EOFWhat it means: You opened a { but never closed it.
Example:
user {name = Joãoage = 25// ❌ Missing }Fix:
user {name = Joãoage = 25} // ✅ Close the objectInvalid Array Syntax
Section titled “Invalid 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
Section titled “Template 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 👹
Section titled “Transpiler Gremlin Errors 👹”The Transpiler Gremlin catches semantic errors — when your JSSON is syntactically correct but logically wrong.
Undefined Reference
Section titled “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 = localhostport = 8080 // ✅ Define port}
url = server.host + ":" + server.port // ✅ Use server.portType Mismatch
Section titled “Type Mismatch”Error:
Transpiler gremlin: 3:10 — Cannot perform operation '+' on boolean and stringWhat it means: You’re trying to combine incompatible types.
Example:
active = truemessage = "Status: " + active // ❌ Can't add boolean to stringFix:
active = "true" // ✅ Make it a stringmessage = "Status: " + activeCommon Mistakes & Solutions
Section titled “Common Mistakes & Solutions”1. Forgetting Quotes
Section titled “1. Forgetting Quotes”Problem:
title = Software Engineer // ❌ Space without quotesSolution:
title = "Software Engineer" // ✅ Use quotes for spaces2. Using JSON Syntax
Section titled “2. Using JSON Syntax”Problem:
user {"name": "João", // ❌ JSON syntax"age": 25,}Solution:
user {name = João // ✅ JSSON syntaxage = 25}3. Missing Commas in Arrays
Section titled “3. Missing Commas in Arrays”Problem:
colors = [ red blue green ] // ❌ Missing commasSolution:
colors = [ red, blue, green ] // ✅ Add commas4. Trailing Commas
Section titled “4. Trailing Commas”Problem:
colors = [ red, blue, green, ] // ❌ Trailing commaSolution:
colors = [ red, blue, green ] // ✅ Remove trailing comma5. Wrong File Extension
Section titled “5. Wrong File Extension”Problem:
jsson -i config.json # ❌ Wrong extensionSolution:
jsson -i config.jsson # ✅ Use .jsson extensionDebugging Tips
Section titled “Debugging Tips”1. Check Line Numbers
Section titled “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
Section titled “2. Look for Unclosed Brackets”If you see EOF (End Of File) errors, you probably forgot to close something:
user {name = Joãoconfig { theme = dark// ❌ Missing } for config// ❌ Missing } for userTip: Use an editor with bracket matching!
3. Validate Incrementally
Section titled “3. Validate Incrementally”Build your JSSON file step by step:
# Start simpleecho 'name = João' > test.jssonjsson -i test.jsson # ✅ Works
# Add moreecho 'age = 25' >> test.jssonjsson -i test.jsson # ✅ Still works
# Keep adding until you find the problem4. Use Comments to Debug
Section titled “4. Use Comments to Debug”Comment out sections to isolate the problem:
user {name = Joãoage = 25}
// database {// host = localhost// port = 5432// }
api {url = "https://api.example.com"}5. Check Your Quotes
Section titled “5. Check Your Quotes”Mixed quotes can cause issues:
name = "João' // ❌ Mismatched quotesname = "João" // ✅ Matching quotesError Message Format
Section titled “Error 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
Section titled “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?
Section titled “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! 🧙♂️👺👹