Need advice about which tool to choose?Ask the StackShare community!
JSON vs Markdown: What are the differences?
Markdown and JSON are both widely used in web development, but they serve different purposes and have distinct features. Here are the key differences between JSON and Markdown:
Structure vs Formatting: JSON is a data interchange format used for storing and transferring structured data, while Markdown is a lightweight markup language used for formatting plain text documents. JSON focuses on representing data in a structured manner, whereas Markdown focuses on enhancing the readability and presentation of text.
Data vs Text: JSON is primarily used for representing and manipulating data, often in the form of objects and arrays. It allows for complex data structures, such as nested objects and arrays, and supports key-value pairs. On the other hand, Markdown is designed for writing and formatting text, providing simple syntax for making the text bold, italic, adding headers, links, etc.
Programmatically Processable vs Human-readable: JSON is designed to be easily parsed and processed by machines, making it an ideal format for transmitting data between a server and a client. It is often used with programming languages and APIs. Markdown, on the other hand, is intended to be readable by humans, allowing for easy editing and collaboration. It is commonly used for writing documentation, blog posts, and other textual content.
Extensibility vs Simplicity: JSON is extensible, meaning users can define and create custom data structures and add additional properties to objects. It provides flexibility in representing complex data types. Markdown, on the other hand, follows a simple and fixed set of formatting rules. While it offers some extensions like tables and task lists, it lacks the extensibility and versatility of JSON.
Strict Syntax vs Loose Syntax: JSON has a strict syntax that requires properly quoted keys and values, as well as correct placement of commas and brackets. It follows a specific set of rules and allows no room for error. Markdown, on the other hand, has a more forgiving and loose syntax. It allows for flexibility in terms of white spaces, line breaks, and formatting, making it easier to write and read.
Data Validation vs Raw Text: JSON supports data validation through various schema languages like JSON Schema. It allows users to define rules and constraints for validating the structure and content of JSON data. Markdown, however, does not have built-in capabilities for data validation. It primarily focuses on the presentation of text and does not provide mechanisms for enforcing data correctness.
In summary, JSON is used for structured data representation and transfer, suitable for machine processing and data validation, while Markdown is a lightweight markup language for text formatting, focusing on human readability and simple syntax.
Hi. Currently, I have a requirement where I have to create a new JSON file based on the input CSV file, validate the generated JSON file, and upload the JSON file into the application (which runs in AWS) using API. Kindly suggest the best language that can meet the above requirement. I feel Python will be better, but I am not sure with the justification of why python. Can you provide your views on this?
Python is very flexible and definitely up the job (although, in reality, any language will be able to cope with this task!). Python has some good libraries built in, and also some third party libraries that will help here. 1. Convert CSV -> JSON 2. Validate against a schema 3. Deploy to AWS
- The builtins include json and csv libraries, and, depending on the complexity of the csv file, it is fairly simple to convert:
import csv
import json
with open("your_input.csv", "r") as f:
csv_as_dict = list(csv.DictReader(f))[0]
with open("your_output.json", "w") as f:
json.dump(csv_as_dict, f)
The validation part is handled nicely by this library: https://pypi.org/project/jsonschema/ It allows you to create a schema and check whether what you have created works for what you want to do. It is based on the json schema standard, allowing annotation and validation of any json
It as an AWS library to automate the upload - or in fact do pretty much anything with AWS - from within your codebase: https://aws.amazon.com/sdk-for-python/ This will handle authentication to AWS and uploading / deploying the file to wherever it needs to go.
A lot depends on the last two pieces, but the converting itself is really pretty neat.
I would use Go. Since CSV files are flat (no hierarchy), you could use the encoding/csv package to read each row, and write out the values as JSON. See https://medium.com/@ankurraina/reading-a-simple-csv-in-go-36d7a269cecd. You just have to figure out in advance what the key is for each row.
This should be pretty doable in any language. Go with whatever you're most familiar with.
That being said, there's a case to be made for using Node.js since it's trivial to convert an object to JSON and vice versa.
Pros of JSON
- Simple5
- Widely supported4
Pros of Markdown
- Easy formatting345
- Widely adopted246
- Intuitive194
- Github integration132
- Great for note taking41
- Defacto GitHub lingo2
Sign up to add or upvote prosMake informed product decisions
Cons of JSON
Cons of Markdown
- Cannot centralise (HTML code needed)2
- Inconsistend flavours eg github, reddit, mmd etc1
- Limited syntax1
- Not suitable for longer documents1
- Non-extensible1
- No right indentation1
- No underline1
- Unable to indent tables1