EDN Format

Use EDN (Extensible Data Notation) format for moclojer configuration. Native Clojure syntax with advanced features, code evaluation, and seamless integration with Clojure projects.

EDN (Extensible Data Notation) is moclojer's native configuration format. As a Clojure-based tool, moclojer has first-class support for EDN, offering the most powerful and flexible configuration option.

πŸ“‹ What You'll Learn

  • βœ… EDN syntax basics and advantages

  • βœ… How to write moclojer configs in EDN

  • βœ… Advanced features (code evaluation, data structures)

  • βœ… When to use EDN vs YAML/OpenAPI

  • βœ… Integration with Clojure projects

🎯 Why Use EDN?

Advantages

βœ… Native format - Direct Clojure data structures βœ… Code evaluation - Execute Clojure expressions βœ… Rich data types - Keywords, symbols, sets, etc. βœ… Comments - Full line and inline comments βœ… No ambiguity - Precise type system βœ… Clojure integration - Use in your Clojure codebase

When to Choose EDN

  • βœ… You're using Clojure/ClojureScript

  • βœ… Need advanced templating features

  • βœ… Want to evaluate code in responses

  • βœ… Prefer precision over readability

  • βœ… Building programmatic configurations

πŸš€ Quick Start

Basic EDN Configuration

Create moclojer.edn:

Run:

Test:

πŸ“– EDN Syntax

Data Types

Complete Example

πŸŽ“ Advanced Features

1. Comments

2. Multi-line Strings

3. Code Evaluation

4. Shared Data

5. Template Variables (Same as YAML)

πŸ“Š EDN vs YAML Comparison

Feature
EDN
YAML

Readability

⭐⭐⭐

⭐⭐⭐⭐⭐

Precision

⭐⭐⭐⭐⭐

⭐⭐⭐

Code evaluation

βœ… Yes

❌ No

Comments

βœ… Yes

βœ… Yes

Native to moclojer

βœ… Yes

❌ No

Clojure integration

⭐⭐⭐⭐⭐

⭐

Learning curve

⭐⭐⭐ (Medium)

⭐⭐ (Easy)

Best for

Clojure devs, advanced features

Beginners, simplicity

βœ… Best Practices

Do βœ…

Don't ❌

πŸ”§ Usage in Clojure Projects

As a Library

Loading from File

πŸ” Troubleshooting

Syntax Errors

Problem: Invalid EDN

Solution: Check for:

  • Unclosed brackets/braces [ { } ]

  • Missing commas in maps (EDN uses whitespace)

  • Invalid characters in keywords

Valid:

Template Variables Not Working

Problem: {{path-params.id}} shows literally

Solution: Template variables work in EDN strings:

πŸ“š See Also

πŸš€ Next Steps


πŸ’‘ Tip: EDN is perfect for Clojure developers who want the full power of Clojure's data structures and code evaluation in their mock configurations!

Last updated

Was this helpful?