MarkCodable - Markdown Codable repo

I just published GitHub - MarkCodable/MarkCodable: Swift Codable with human-friendly Markdown storage.

It's a Codable implementation that encodes into Markdown text and decodes from Markdown.

For fairly simple data structures it offers a numbers of benefits over JSON:

  • humans can view/edit the data in a plain text editor or online in a text field
  • the data can be easily embedded in Swift code as a string and still be readable/editable
  • tabular representation is easier to parse for humans than JSON

Here are some of the use cases in which you could use MarkCodable.

Configuration files

Markdown is a viable alternative to json or yml files, especially for multiple configuration entries like per-environment or per-domain configurations, for example:

| environment | host      | port | user | schema |
|-------------|-----------|------|------|--------|
| qa          | 127.0.0.1 | 8080 | test | http   |
| production  | 2.317.1.2 | 9999 | app  | https  |

Test and mock objects

In unit tests you often times need a number of test objects to create the test setup. Those are sometimes a bit clunky to always create in code so you can either include the Markdown in your tests or have it as an .md file in your test bundle:

| userID | name | age | permissions |
|--------|------|-----|-------------|
|1       |peter | 32  |read         |
|2       |admin | 100 |read,write   |

Markdown-driven app backend

To show how easy it is to replace an app's backend with a markdown file hosted on github I also published this demo repo: https://github.com/icanzilb/MarkCodingDemoApp

Enjoy & let me know your feedback
— Marin

8 Likes