Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonConverter for Converting JSON Files into Structured Markdown Files #251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ZeyuTeng96
Copy link

This PR implements a JsonConverter class that converts JSON files into Markdown files while preserving the dictionary structure of the data to the greatest extent possible during the conversion process.

  • For JSON files with dict like:

image

The conversion result will be:
image

  • For JSON files containing a list of dicts, such as the SFT fine-tuning data for LLMs:
    image

The conversion result will display each element of the list in sequence. Additionally, users can customize the value of the list heading (default is Elem):
image

This conversion approach preserves the dictionary structure to the greatest extent possible, allowing converted .md files to be more intuitively readable and visually clear for users. Furthermore, when performing retrieval-augmented generation (RAG), LLMs are highly familiar with dict structure and can process them effectively.

Converts Jsons to Markdown. The output preserves the structure of the JSON file as closely as possible, while using Markdown syntax for readability.
@ZeyuTeng96
Copy link
Author

@microsoft-github-policy-service agree

@afourney
Copy link
Member

afourney commented Jan 4, 2025

Thanks for the PR! We appreciate it!

Both #219 and this PR propose alternative ways of converting JSON to Markdown.
An alternative approach would also be to simply quote the json (perhaps pretty-printed) in a Markdown code block.

Ideally, we would have a clean way of registering/unregistering different converters, so that people can customize the library to their desire (e.g., by picking from the 3 above-mentioned approaches). I think this is coming in the new year, and will discuss with my team when everyone is back.

Until then, I'm not sure I am ready to pick a default behavior yet (beyond treating it as plain text -- which is what was intended)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants