Skip to content
Advertisement

Python: Convert markdown table to json with

I am trying to figure out, what is the easiest way to convert some markdown table text into json using only python. For example, consider this as input string:

JavaScript

The wanted output should be this:

JavaScript

Note: Ideally, the output should be RFC 8259 compliant, aka use double quotes ” instead of single quotes ‘ around they key value pairs.

I’ve seen some JS libraries that do that, but nothing for python only. Can someone explain to me whats the quickest way to achieve this, so I don’t have to write my own parser for this.

All help is appreciated!

Advertisement

Answer

You can treat it as a multi-line string and parse it line by line while splitting at n and |

Simple code that does that:

JavaScript
JavaScript

PS: Don’t know about any library that does that, will update if I find anything!

Advertisement