Working with JSON Documents in ATOM editor

29/12/2020
Chưa phân loại
In this post we will see how we can maximize our speed and performance while working with JSON documents in ATOM text editor. We will learn few shortcuts and some capabilities Atom editor offers while working with standard JSON.

Getting Started

Visit the Atom homepage to download and install the latest version of the editor for your Operating System. Optionally, you can also explore Themes and packages available for Atom. Here is what Atom looks like when it is opened:

Atom Editor home screen

Working with a JSON Document

We will create a JSON file to start with. To do so, press “Cmd + N” on Mac (Ctrl + N for Ubuntu/Windows) and paste some JSON content inside it. We use the following JSON object:

{
  "book_name" : "MongoDB",
  "author" : [
      {
        "name" : "Oshima"
      },
      {
        "name" : "Shubham"
      }
    ]
}

When you save the file with the “.json” extension, we will immediately see that JSON document is highlighted (based on your current theme):

JSON is Highlighted

If you try, you will find that you cannot fold the JSON documents on various levels which is often a needed feature. Let’s enable this feature in next section.

JSON Code Folding

To enable the code-folding feature of JSON documents, we need to install an Atom package as code-folding feature of JSON documents is not available by default. To achieve this, we need to install a new package for Atom known as Beautify. Follow the instructions mentioned on provided link to install this package for Atom. Or just follow the instructions here:

Settings/Preferences ➔ Packages ➔ Search for atom-beautify

Here is what we get back with this command:

Atom Beautify package

Now, once you restart the Atom editor, we will see the following arrows in the JSON document:

Code-fold arrows in JSON

You can try clicking on these arrows to fold the JSON at a given depth.

JSON Code Formatting

Code Formatting feature of JSON documents is not available by default in the Atom editor. We need to install a package for this task as well. Luckily, the package we installed last performs this function as well. So, if you have badly formatted JSON like:

{
  "book_name" : "MongoDB",
  "author" : [
      {
        "name" : "Oshima"},
      {"name" : "Shubham"
  }
    ]
}

We can simply click CTRL + ALT + B (on all Operating Systems) to beautify the JSON data in the file.

Conclusion

In this lesson we looked at how we can make and work with JSON Documents in one of the most popular text editor, Atom.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Use the rm Command in Linux

The rm command is used to remove files and directories in Linux. This is one of the commands that you must know as a Linux...
29/12/2020

[NGINX] Hướng dẫn cài đặt Nginx trên CentOS 8

NGINX (đọc là “engine x”) là một phần mềm mã nguồn mở cho web serving, reverse proxying, caching,...
30/12/2020

Install Visual Studio Code Arch Linux

Visual Studio Code is a great programming text editor. It is beautiful and lightweight. It is loved by many programmers...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025

Dịch Vụ Triển Khai VPN Site-to-Site & Remote Access
04/04/2025

Dịch Vụ Thiết Lập Hệ Thống Tường Lửa (Firewall)
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ảo Hóa & Cloud
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ceph
04/04/2025