I've heard about MongoDB, but I'm not sure I fully understand the concept.

If I have multiple JSON objects stored in MongoDB:

[{"id": "peter",
  "age": "12",
  "gender": "male"},
 {"id": "gemma",
  "age": "12",
  "gender": "female"},
 {"id": "paul",
  "age": "13",
  "gender": "male"}]

How would I be able to query all JSON objects with age >= 12?

推荐答案

First of all, understand that JSON is just a serialization technique. In and of itself, this serialization method probably should not determine your persistence medium. Looking at your question on the surface, it seems like what you are looking for is a typical relational storage database where you can use SQL to query against your data in a flexible manner.

Serializing/deserializing JSON data for storage into or for presentation after retrieval from such a relational database is trivial in pretty much any programming language.

Now if you truly need to store various snippets of JSON documents (or any other sort of document) that don't really have a fixed structure, that is really when you typically would start looking at a NoSQL type of solution such as MongoDB. One other possible such scenario for using the more popular NoSQL databases is when you are dealing with massive amounts of data and need to scale horizontally (i.e. the data is so large you need to scale the database across multiple servers). Many NoSQL systems make this much easier to do than traditional relational DB's. Of course in such a scenario, you would then need to evaluate those tools based on the functionality they provide in allowing you to read, write, and query data in the most useful manner for your use case(s).

Json相关问答推荐

JOLT转换,将属性复制到同级别的dict中

Google Page to JSON应用程序脚本出现CORS错误

Jolt需要将缺少的值设置为空并保持相同的位置

褐煤面积图中的分选问题

如何在JSONata对象中迭代并向数组添加新字段?

将JSON数组组织到菜单中

交换键和数组值,将旧键转换为新数组值,使用 jq

Moshi:序列化 List 时出现问题

在 VS Code 中将一个正则表达式替换为另一个正则表达式

Jolt - 如何比较 if else 条件的两个值

迭代powershell双维json对象

将 colly 包输出文本添加到 golang 中的映射

在 postgresql 中将行转换为 json 对象

判断 JSON 中的对象,而不是条件中提到的对象

如何从 rails 中的 respond_to 方法生成 json?

在视图中将 .Net 对象转换为 JSON 对象

PostgreSQL 中的 JSON 模式验证?

在浏览器中查看 JSON 文件

Jackson JSON序列化,通过级别定义避免递归

FastAPI:如何将正文读取为任何有效的 json?