Jun 21, 2020
3 mins read
To create a JSON file, first, we need to understand what JSON is and what it represents. Please check out this link to find out more about JSON. What is JSON?
Once we understand JSON, there are three ways to create a new JSON.
Open a Text editor like Notepad, Visual Studio Code, Sublime, or your favorite one.
Copy and Paste below JSON data in Text Editor or create or use your JSON based on the What is JSON article.
|
|
Use this JSON validator tool to validate the JSON
https://codebeautify.org/jsonvalidator
Once file data are validated, save the file with the extension of .json, and now you know how to create a Valid JSON document.
Open a JSON Formatter tool from the link below
https://jsonformatter.org
or
https://codebeautify.org/jsonviewer
Copy and Paste the JSON Data, which is mentioned in Option 1 in the Input tool of the online tool
Download this file using the download icon mentioned in the Right input area. It will download the JSON file.
This jsonformatter.org already supports the JSON validation. It will create a New JSON file and will allow downloading.
Now, if you already have a JSON document or file, you can upload it to this tool, modify or delete a few objects, an array of the JSON, and download the updated and valid JSON file.
This tool also helps to create a JSON from a text file. Upload text files using the upload file button, and JSON will be automatically validated and beautified.
The developer needs to work with API; nowadays, 95% of API returns data as JSON.
Here are a few samples of the JSON URL. Now click on these JSON samples.
Once these links are open, “save as” the browser’s functionality and save these links as files. It will generate a JSON file and save it on your device.
I hope this article helps you to understand basic ways to make or create valid JSON files and beautify them.
Use the jq command to create a JSON file in Linux. This command will build a JSON file in the current directory.
jq -n --arg greeting GoodMorning
'{"hello":$greeting}' > sample.json
the jq is a lightweight and flexible command-line JSON processor. Install the jq in ubuntu using the sudo apt-get install jq
Sharing is caring!