生成的数据
JSON数据操作类可对各种复杂JSON,读取、生成、删除 By HT.Liu
-----------------------------------------------------
JSON原始数据
-----------------------------------------------------
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumber": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
],
"rows": [
[
1,
2,
3
],
[
4,
5,
6
]
]
}
-----------------------------------------------------
JSON数据读取
-----------------------------------------------------
firstName:John
lastName:Smith
age:25
address.streetAddress:21 2nd Street
phoneNumber[0].type:home
phoneNumber[1].type:fax
rows[0][0]:1
rows[1][0]:4
rows长度:2
home: 212 555-1234
fax: 646 555-4567
rows[0]:1-2-3
rows[1]:4-5-6
-----------------------------------------------------
在原始数据基础上更新、删除,并生成新的JSON
-----------------------------------------------------
输出格式:多行
{
"firstName": "HaiTao",
"lastName": "Liu",
"age": 38,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumber": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
输出格式:单行压缩
{"firstName":"HaiTao","lastName":"Liu","age":38,"address":{"streetAddress":"21 2nd Street","city":"New York","state":"NY","postalCode":"10021"},"phoneNumber":[{"type":"home","number":"212 555-1234"},{"type":"fax","number":"646 555-4567"}]}
-----------------------------------------------------
多方式生成JSON,操作多样化,选一种喜欢的
-----------------------------------------------------
类底层基础操作,其它方式均在此基础上优化
-----------------------------------------------------
{
"familyName": "\u7F8E\u597D\u4E00\u5BB6",
"msg": "OK",
"total": 3,
"familyMembers": [
{
"firstName": "John",
"age": 41
},
{
"firstName": "Suzan",
"age": 38,
"interests": [
"Reading",
"Tennis",
"Painting"
]
},
{
"firstName": "John Jr.",
"age": 2.5
}
]
}
-----------------------------------------------------
Asp基本赋值方式(1)-生成数据如下:
-----------------------------------------------------
{
"familyName": "\u7F8E\u597D\u4E00\u5BB6",
"msg": "OK",
"total": 3,
"familyMembers": [
{
"firstName": "John",
"age": 41
},
{
"firstName": "Suzan",
"age": 38,
"interests": [
"Reading",
"Tennis",
"Painting"
]
},
{
"firstName": "John Jr.",
"age": 2.5
}
]
}
-----------------------------------------------------
Asp快速赋值方式(2)-生成数据如下:
-----------------------------------------------------
{
"familyName": "\u7F8E\u597D\u4E00\u5BB6",
"msg": "OK",
"total": 3,
"familyMembers": [
{
"firstName": "John",
"age": 41
},
{
"firstName": "Suzan",
"age": 38,
"interests": [
"Reading",
"Tennis",
"Painting"
]
},
{
"firstName": "John Jr.",
"age": 2.5
}
]
}
-----------------------------------------------------
Asp直观赋值方式(3)-生成数据如下:
-----------------------------------------------------
{
"familyName": "\u7F8E\u597D\u4E00\u5BB6",
"msg": "OK",
"total": 3,
"familyMembers": [
{
"firstName": "John",
"age": 41
},
{
"firstName": "Suzan",
"age": 38,
"interests": [
"Reading",
"Tennis",
"Painting"
]
},
{
"firstName": "John Jr.",
"age": 2.5
}
]
} |