JSON 对象示例:带嵌套对象
JSON 对象示例:带嵌套对象
JSON (JavaScript 对象表示法) 是一种轻量级的数据交换格式,常用于 Web 应用和 API 通信。JSON 对象可以包含嵌套对象,以表示更复杂的数据结构。
案例 1:人员信息
{
'name': 'John',
'age': 25,
'address': {
'street': '123 Main Street',
'city': 'New York',
'state': 'NY',
'zipcode': '10001'
}
}
案例 2:书籍信息
{
'title': 'The Great Gatsby',
'author': 'F. Scott Fitzgerald',
'year': 1925,
'publisher': {
'name': 'Scribner',
'location': 'New York'
}
}
案例 3:产品信息
{
'product': 'iPhone 12',
'brand': 'Apple',
'price': 999,
'specs': {
'display': '6.1 inches',
'camera': 'Dual 12 MP',
'storage': '64 GB'
}
}
这些示例展示了如何使用 JSON 对象表示包含嵌套对象的结构化数据。嵌套对象可以用来组织数据,使之更易于理解和使用。
原文地址: https://www.cveoy.top/t/topic/qmZV 著作权归作者所有。请勿转载和采集!