🌐
SitePoint
sitepoint.com › blog › apis › database json file
Database JSON File — SitePoint
February 12, 2024 - This means you can export data in JSON format from one NoSQL database like Mongo, and import the same data to another NoSQL database like RethinkDB without doing any conversion. In this example, we are going to look at a JSON file created using a generator that can be imported into a NoSQL database such as Mongo.
🌐
Goanywhere
goanywhere.com › resources › training › how-to-read-json-and-insert-into-database
How to Read JSON Data and Insert it into a Database Training Page | GoAnywhere
For example, you could have a JSON file that contains customer information along with a list of the products the customer ordered. The customer information can be parsed into one RowSet and the list of products into another RowSet. Those RowSet variables can then be inserted into two separate ...
Discussions

Learn How to Use JSON as a Small Database for Your Py Projects by Building a Hotel Accounting System
u/RevolutionaryAd8906 , I appreciate your good intentions in creating a beginner-friendly tutorial like this. JSON is a core technology that anyone working with modern APIs should understand, and it's important to make learning accessible for beginners. That said, your mindset of setting up JSON to be thought of as a "database" is perhaps sub-optimal ... while it's useful to teach data persistence early on, positioning JSON as a database can set beginners up for struggles down the line. I think you know this, and I see where you're going with it, but fundamentally it sets up a paradigm in the heads of new programmers that is misaligned with best practices. JSON files are easy to use and understand, making them great for small projects or single-user applications. Maybe a to-do list or managing simple configuration settings, storing user preferences, tracking small collections (e.g., book or movie lists). JSON works well if the scale is very limited. The progression from using JSON for data storage to interacting with APIs is logical and effective. However the limitations of JSON are very quickly apparent: Scalability: JSON is not designed for large datasets (like managing a hotel............. maybe suggest a different example in your HOW TO?) Performance degrades significantly with thousands of records, as the entire file must be read and written each time. RAM also becomes a limiting factor. Beyond a few thousand records, load and save times will noticeably degrade, especially with detailed records. Concurrency: JSON does not handle concurrent access. When multiple users or processes interact with the data, conflicts and errors are likely. Traditional databases manage this with record locking, transactions, and ACID compliance. Data Integrity and Security: JSON lacks built-in features for enforcing data types, constraints, or relationships. Storing sensitive information in plain-text JSON without encryption is risky (like the hotel guests credit card numbers and addresses...??) Databases like SQLite or even NoSQL options like MongoDB help mitigate these issues. Integrating databases from the beginning with new programming students can be valuable and I would argue worth doing. It seems to me you're kicking a can down the line and instilling a bad notion in their heads that they can use JSON as a flat file database. SQLite, for instance, requires minimal setup and offers skills that are more transferable to complex projects. It introduces concepts like relationships, querying, and data normalization, which can save a lot of headaches later on. I wonder if there's a middle ground where you introduce data persistence with JSON, and then transition to something like SQLite or an ORM in short order? This would help beginners avoid the pitfalls of using JSON beyond its intended use while still learning important concepts in a manageable way. Anyway ... not trying to criticize too harshly, but I think this is a misguided way to teach what JSON is all about. More on reddit.com
🌐 r/Python
36
48
August 21, 2024
mysql - Storing JSON in database vs. having a new column for each key - Stack Overflow
Importantly: if the majority of ... using JSON, you might want to at least consider if a relational database is the right choice. That said, few applications are perfectly relational or document-oriented. Most applications have some mix of both. Here are some examples where I personally ... More on stackoverflow.com
🌐 stackoverflow.com
Can i use JSON file to store data, instead of database? If possible, is it good idea?
Yes, but you would eventually end up reinventing something that looks like Mongodb, which does store its data in Json format, but also has a powerful engine and api, providing things like fast retrieval, search queries, clustering, etc. Why not just use something that's free, and that other people have already done the hard work for? More on reddit.com
🌐 r/webdev
46
30
April 15, 2022
Does anyone use JSON files as a database? Best practises? Or should I use a "real" database?
I've written repository implementations that use JSON file as a datastore. But only in tests and local dev, never in production where a database is used as the datastore. A few reasons why JSON files aren't a good fit: JSON has poor type support (as does JS as a language) JSON is bloated when compared to DB implementations that use some sort of binary format: high memory usage when in-memory, higher disk usage when on-disk You need to write operations like filter, fetch, merge etc. your self that the database implementation drivers normally offer and hide from user (obviously this could be written as library code) ACID in databases are offered by the engine which you need to implement yourself. You mentioned data loss as one DB engines allow scaling vertically or horizontally if needed Database engines offer optimisations and indexing by way smarter people than either of us. Also the data can easily be crypted and backed up if desired So unless the projects have very few, non-concurrent users and you don't mind paying big bucks for a server, I'd suggest moving along with a database. Be it document store, key-value store or relational database More on reddit.com
🌐 r/node
44
22
January 29, 2023
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › relational-databases › json › json-data-sql-server
Work with JSON Data in SQL Server - SQL Server | Microsoft Learn
If you have JSON text that's stored in database tables, you can read or modify values in the JSON text by using the following built-in functions: ISJSON tests whether a string contains valid JSON. JSON_VALUE extracts a scalar value from a JSON string. JSON_QUERY extracts an object or an array from a JSON string. JSON_MODIFY changes a value in a JSON string. ... In the following example, the query uses both relational and JSON data (stored in a column named jsonCol) from a table called People:
🌐
JSON
json.org › example.html
JSON Example
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd"> <web-app> <servlet> <servlet-name> cofaxCDS </servlet-name> <servlet-class> org.cofax.cds.CDSServlet </servlet-class> <init-param> <param-name>configGlossary:installationAt</param-name> <param-value>Philadelphia, PA</param-value> </init-param> <init-param> <param-name>configGlossary:adminEmail</param-name> <param-value>ksm@pobox.com</param-value> </init-param> <init-param> <param-name>configGlossary:poweredBy</param-name>
🌐
Oracle
docs.oracle.com › en › database › other-databases › nosql-database › 25.3 › java-driver-table › json-example.html
JSON By Example - NoSQL Database
November 19, 2025 - The example loads a series of table rows, using JSON objects to represent each row. The example then updates all table rows that contain a home address in Boston so that the zip code for that address is updated from 02102 to 02102-1000.
🌐
MongoDB
mongodb.com › resources › basics › databases › json-database
What Is A JSON Database? | All You Need To Know | MongoDB | MongoDB
This means that data doesn’t have to be normalized to accommodate them into multiple tables with fixed structure, like in a relational database. Examples of JSON document databases are MongoDB, DocumentDB, and CouchDB.
🌐
Redis
redis.io › home
A Guide to Understanding JSON Databases | Redis
March 27, 2025 - Anything that makes it easy for humans to understand is valuable – and more so given the ease by which data in JSON databases can be parsed. JSON is lightweight. It has little formatting overhead (compared to XML, which is chatty). That can be meaningful in the amount of bandwidth needed to transmit data or store it. Developers can establish data relationships in a self-documenting fashion. In the cat example above, you need to do only one query to get the data for both the name field “Jason” and the cat’s value “floofy”. That can offer a performance boost as well.
Find elsewhere
🌐
W3Schools
w3schools.com › js › js_json.asp
W3Schools.com
JSON Intro JSON Syntax JSON vs XML JSON Data Types JSON Parse JSON Stringify JSON Objects JSON Arrays JSON Server JSON PHP JSON HTML JSON JSONP JS jQuery · jQuery Selectors jQuery HTML jQuery CSS jQuery DOM JS Graphics · JS Graphics JS Canvas JS Plotly JS Chart.js JS Google Chart JS D3.js JS Examples
🌐
JSON Schema
json-schema.org › learn › json-schema-examples
JSON Schema - JSON Schema examples
{ "$id": "https://example.com/blog-post.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "A representation of a blog post", "type": "object", "required": ["title", "content", "author"], "properties": { "title": { "type": "string" }, "content": { "type": "string" }, "publishedDate": { "type": "string", "format": "date-time" }, "author": { "$ref": "https://example.com/user-profile.schema.json" }, "tags": { "type": "array", "items": { "type": "string" } } }}
🌐
Adobe
opensource.adobe.com › Spry › samples › data_region › JSONDataSetSample.html
JSON Data Set Sample
The JSON output from different Server APIs can range from simple to highly nested and complex. The examples on this page attempt to illustrate how the JSON Data Set treats specific formats, and gives examples of the different constructor options that allow the user to tweak its behavior.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › JSON
Working with JSON - Learn web development | MDN
If you load this JSON in your JavaScript program as a string, you can parse it into a normal object and then access the data inside it using the same dot/bracket notation we looked at in the JavaScript object basics article. For example:
🌐
DuckDB
duckdb.org › docs › stable › data › json › overview
JSON Overview – DuckDB
DuckDB supports SQL functions that are useful for reading values from existing JSON and creating new JSON data. JSON is supported with the json extension which is shipped with most DuckDB distributions and is auto-loaded on first use. If you would like to install or load it manually, please ...
🌐
Reddit
reddit.com › r/python › learn how to use json as a small database for your py projects by building a hotel accounting system
r/Python on Reddit: Learn How to Use JSON as a Small Database for Your Py Projects by Building a Hotel Accounting System
August 21, 2024 -

This is the first free tutorial designed to help beginners learn how to use JSON to create a simple database for their projects.

It also prepares developers for the next two tutorials in our "Learn by Build" series, where we'll cover how to use the requests library, build asynchronous code, and work with threads.

and by time we will add extra more depth projects to enhance your pythonic skills

find tutorial in github https://github.com/rankap/learn_by_build/tree/main/tut_1_learn_json

Top answer
1 of 5
15
u/RevolutionaryAd8906 , I appreciate your good intentions in creating a beginner-friendly tutorial like this. JSON is a core technology that anyone working with modern APIs should understand, and it's important to make learning accessible for beginners. That said, your mindset of setting up JSON to be thought of as a "database" is perhaps sub-optimal ... while it's useful to teach data persistence early on, positioning JSON as a database can set beginners up for struggles down the line. I think you know this, and I see where you're going with it, but fundamentally it sets up a paradigm in the heads of new programmers that is misaligned with best practices. JSON files are easy to use and understand, making them great for small projects or single-user applications. Maybe a to-do list or managing simple configuration settings, storing user preferences, tracking small collections (e.g., book or movie lists). JSON works well if the scale is very limited. The progression from using JSON for data storage to interacting with APIs is logical and effective. However the limitations of JSON are very quickly apparent: Scalability: JSON is not designed for large datasets (like managing a hotel............. maybe suggest a different example in your HOW TO?) Performance degrades significantly with thousands of records, as the entire file must be read and written each time. RAM also becomes a limiting factor. Beyond a few thousand records, load and save times will noticeably degrade, especially with detailed records. Concurrency: JSON does not handle concurrent access. When multiple users or processes interact with the data, conflicts and errors are likely. Traditional databases manage this with record locking, transactions, and ACID compliance. Data Integrity and Security: JSON lacks built-in features for enforcing data types, constraints, or relationships. Storing sensitive information in plain-text JSON without encryption is risky (like the hotel guests credit card numbers and addresses...??) Databases like SQLite or even NoSQL options like MongoDB help mitigate these issues. Integrating databases from the beginning with new programming students can be valuable and I would argue worth doing. It seems to me you're kicking a can down the line and instilling a bad notion in their heads that they can use JSON as a flat file database. SQLite, for instance, requires minimal setup and offers skills that are more transferable to complex projects. It introduces concepts like relationships, querying, and data normalization, which can save a lot of headaches later on. I wonder if there's a middle ground where you introduce data persistence with JSON, and then transition to something like SQLite or an ORM in short order? This would help beginners avoid the pitfalls of using JSON beyond its intended use while still learning important concepts in a manageable way. Anyway ... not trying to criticize too harshly, but I think this is a misguided way to teach what JSON is all about.
2 of 5
8
Students would be far better served by studying examples of database centered applications built around SQLite (an SQL standards compliant database system embedded in the Python standard libraries). JSON is not suitable as a format for database management. None of the JSON accessibility APIs provides support for ACID transaction management, record (table nor row level) locking, schema definition and enforcement, normalization and JOINs, no indexing. This is a lot of code you'd have to write into the front end that no sane, modern, production database application would implement. Database management engines implement those features. Students are better served using tools and frameworks which offer features and APIs similar to those used in real world, production applications.
🌐
SitePoint
sitepoint.com › blog › javascript › json server example
JSON Server Example — SitePoint
February 12, 2024 - You can add data to your JSON Server by modifying the db.json file. This file acts as your database, and each key in the JSON object corresponds to a different resource. For example, if you want to add a new post, you would add a new object to the posts array in your db.json file.
Top answer
1 of 10
307

Updated 4 June 2017

Given that this question/answer have gained some popularity, I figured it was worth an update.

When this question was originally posted, MySQL had no support for JSON data types and the support in PostgreSQL was in its infancy. Since 5.7, MySQL now supports a JSON data type (in a binary storage format), and PostgreSQL JSONB has matured significantly. Both products provide performant JSON types that can store arbitrary documents, including support for indexing specific keys of the JSON object.

However, I still stand by my original statement that your default preference, when using a relational database, should still be column-per-value. Relational databases are still built on the assumption of that the data within them will be fairly well normalized. The query planner has better optimization information when looking at columns than when looking at keys in a JSON document. Foreign keys can be created between columns (but not between keys in JSON documents). Importantly: if the majority of your schema is volatile enough to justify using JSON, you might want to at least consider if a relational database is the right choice.

That said, few applications are perfectly relational or document-oriented. Most applications have some mix of both. Here are some examples where I personally have found JSON useful in a relational database:

  • When storing email addresses and phone numbers for a contact, where storing them as values in a JSON array is much easier to manage than multiple separate tables

  • Saving arbitrary key/value user preferences (where the value can be boolean, textual, or numeric, and you don't want to have separate columns for different data types)

  • Storing configuration data that has no defined schema (if you're building Zapier, or IFTTT and need to store configuration data for each integration)

I'm sure there are others as well, but these are just a few quick examples.

Original Answer

If you really want to be able to add as many fields as you want with no limitation (other than an arbitrary document size limit), consider a NoSQL solution such as MongoDB.

For relational databases: use one column per value. Putting a JSON blob in a column makes it virtually impossible to query (and painfully slow when you actually find a query that works).

Relational databases take advantage of data types when indexing, and are intended to be implemented with a normalized structure.

As a side note: this isn't to say you should never store JSON in a relational database. If you're adding true metadata, or if your JSON is describing information that does not need to be queried and is only used for display, it may be overkill to create a separate column for all of the data points.

2 of 10
127

Like most things "it depends". It's not right or wrong/good or bad in and of itself to store data in columns or JSON. It depends on what you need to do with it later. What is your predicted way of accessing this data? Will you need to cross reference other data?

Other people have answered pretty well what the technical trade-off are.

Not many people have discussed that your app and features evolve over time and how this data storage decision impacts your team.

Because one of the temptations of using JSON is to avoid migrating schema and so if the team is not disciplined, it's very easy to stick yet another key/value pair into a JSON field. There's no migration for it, no one remembers what it's for. There is no validation on it.

My team used JSON along side traditional columns in postgres and at first it was the best thing since sliced bread. JSON was attractive and powerful, until one day we realized that flexibility came at a cost and it's suddenly a real pain point. Sometimes that point creeps up really quickly and then it becomes hard to change because we've built so many other things on top of this design decision.

Overtime, adding new features, having the data in JSON led to more complicated looking queries than what might have been added if we stuck to traditional columns. So then we started fishing certain key values back out into columns so that we could make joins and make comparisons between values. Bad idea. Now we had duplication. A new developer would come on board and be confused? Which is the value I should be saving back into? The JSON one or the column?

The JSON fields became junk drawers for little pieces of this and that. No data validation on the database level, no consistency or integrity between documents. That pushed all that responsibility into the app instead of getting hard type and constraint checking from traditional columns.

Looking back, JSON allowed us to iterate very quickly and get something out the door. It was great. However after we reached a certain team size it's flexibility also allowed us to hang ourselves with a long rope of technical debt which then slowed down subsequent feature evolution progress. Use with caution.

Think long and hard about what the nature of your data is. It's the foundation of your app. How will the data be used over time. And how is it likely TO CHANGE?

🌐
Stack Overflow
stackoverflow.blog › 2022 › 06 › 02 › a-beginners-guide-to-json-the-data-format-for-the-internet
A beginner's guide to JSON, the data format for the internet - Stack Overflow
Currently, you can get equivalent functionality by exporting a JavaScript Object the same as your desired JSON from a JavaScript file. ... Now this object will be stored in the constant, data, and will be accessible throughout your application using import or require statements. Note that this will import a copy of the data, so modifying the object won’t write the data back to the file or allow the modified data to be used in other files. Once you have a variable containing your data, in this example data, to access a key’s value inside it, you could use either data.key or data["key"]. Square brackets must be used for array indexing; for example if that value was an array, you could do data.key[0], but data.key.0 wouldn’t work.
🌐
GitHub
github.com › typicode › lowdb
GitHub - typicode/lowdb: Simple and fast JSON database · GitHub
This is because whenever you call db.write, the whole db.data is serialized using JSON.stringify and written to storage. Depending on your use case, this can be fine or not. It can be mitigated by doing batch operations and calling db.write only when you need it. If you plan to scale, it's highly recommended to use databases like PostgreSQL or MongoDB instead.
Starred by 22.5K users
Forked by 960 users
Languages   JavaScript 99.1% | Shell 0.9%
🌐
Json-ld
json-ld.org
JSON-LD - JSON for Linked Data
It is easy for humans to read and write. It is based on the already successful JSON format and provides a way to help JSON data interoperate at Web-scale. JSON-LD is an ideal data format for programming environments, REST Web services, and unstructured databases such as Apache CouchDB and MongoDB.
🌐
Couchbase
couchbase.com › home › how to model data: a guide to json data modeling
JSON Data Modeling: Design, Structure, Migration Tools, & More
November 18, 2025 - We’ll then instruct you on how to transform and structure that data on the document database side and finalize our data using the SQL++ query language. With SQL++, we can move data from a staging point to a final data bucket ready for use. This video is chock full of real code examples allowing you to follow along and try it yourself. ... Here is an article on the same topic if you prefer scanning a blog article over watching the entire video. ... You can also check out the following JSON data video: Model Your Relational Database Data as NoSQL Document Data, which contains additional insights and walkthroughs.