Incwadi Yomsebenzisi Yokuhumusha ye-API
bonisa:
sebenzisa
Db::return_json_exit()
Uma usebenzisa indlela, ungacacisa indlela yensimu okufanele ihunyushwe ngepharamitha yesibili.
Ukusetshenziswa okuyisisekelo
1. Humusha izinkambu ezithile
Humusha wonke umbhalo wesiShayina ngaphansi kwe-`pricing_plans` kanye nenani le-`message`:
Db::return_json_exit([
'code' => 200,
'message' => '成功',
'data' => [
'pricing_plans' => [
'basic' => [
'name' => '基础套餐',
'price' => 99,
'features' => ['功能一', '功能二']
],
'pro' => [
'name' => '专业套餐',
'price' => 299,
'features' => ['高级功能', '优先支持']
]
],
'user' => [
'name' => '张三',
'profile' => [
'city' => '北京',
'bio' => '个人简介'
]
],
'aaa' => '你好'
]
], ['data.pricing_plans.*', 'message']);
2. Humusha izindlela ezithile kanye nezindlela ezincane
Humusha zonke izinhlamvu zesiShayina ngaphansi kwegama lenkambu ethile kanye ne-pro:
Db::return_json_exit([
'code' => 200,
'message' => '成功',
'data' => [
'pricing_plans' => [
'basic' => [
'name' => '基础套餐',
'price' => 99,
'features' => ['功能一', '功能二']
],
'pro' => [
'name' => '专业套餐',
'price' => 299,
'features' => ['高级功能', '优先支持']
]
],
'user' => [
'name' => '张三',
'profile' => [
'city' => '北京',
'bio' => '个人简介'
]
],
'aaa' => '你好'
]
], ['data.pricing_plans.basic.name', 'data.pricing_plans.pro.*']);
3. Humusha yonke into yedatha
Humusha konke okuqukethwe ngaphansi kwefolda yedatha usebenzisa ama-wildcard:
Db::return_json_exit([
'code' => 200,
'message' => '成功',
'data' => [
'pricing_plans' => [
'basic' => [
'name' => '基础套餐',
'price' => 99,
'features' => ['功能一', '功能二']
],
'pro' => [
'name' => '专业套餐',
'price' => 299,
'features' => ['高级功能', '优先支持']
]
],
'user' => [
'name' => '张三',
'profile' => [
'city' => '北京',
'bio' => '个人简介'
]
],
'aaa' => '你好'
]
], ['data.*']);
4. Ungahumushi (okuzenzakalelayo)
Ipharamitha yesibili ayifakiwe, futhi akukho ukuhumusha okwenziwayo:
Db::return_json_exit([
'code' => 200,
'message' => '成功',
'data' => [
'pricing_plans' => [
'basic' => [
'name' => '基础套餐',
'price' => 99,
'features' => ['功能一', '功能二']
],
'pro' => [
'name' => '专业套餐',
'price' => 299,
'features' => ['高级功能', '优先支持']
]
],
'user' => [
'name' => '张三',
'profile' => [
'city' => '北京',
'bio' => '个人简介'
]
],
'aaa' => '你好'
]
]);
Incazelo ye-syntax yendlela
field- Humusha izinkambu zezinga eliphezuludata.field- Humusha amasimu afakwe izidlekedata.*- Zonke izinkambu ngaphansi kwento yokuhumushadata.array.*- Humusha konke okuqukethwe ngaphansi kwe-array/object