我如何从扑朔迷离中从HTTP方法中获得特定值?
我的输出是这样的:
{
"scope": [],
"_id": "62413827f85e740dd8af749d",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJpc3N1ZXIiLCJzdWIiOnsidXNlcklkIjoiNjI0MTM4MjdmODVlNzQwZGQ4YWY3NDlhIn0sImlhdCI6MTY0ODQ0MTM4M30.cNE32yojMlbohsOtgB2docCsZk8UPqEbPVTizV--rMs",
"user": {
"_id": "62413827f85e740dd8af749a",
"email": "[email protected]",
"password": "hello",
"phone": "01723456789",
"createdAt": "2022-03-28T04:23:03.334Z",
"updatedAt": "2022-03-28T04:23:03.334Z",
"__v": 0
},
"createdAt": "2022-03-28T04:23:03.348Z",
"updatedAt": "2022-03-28T04:23:03.348Z",
"__v": 0
}
How can I get the value of "email" from "user" in flutter?我正在使用以下代码。
http
.post(Uri.parse(url),
headers: {"Content-type": "application/json;charset=UTF-8"},
body: jsonEncode(model))
.then((value) {
var access = jsonDecode(value.body);
My output is like this:
{
"scope": [],
"_id": "62413827f85e740dd8af749d",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJpc3N1ZXIiLCJzdWIiOnsidXNlcklkIjoiNjI0MTM4MjdmODVlNzQwZGQ4YWY3NDlhIn0sImlhdCI6MTY0ODQ0MTM4M30.cNE32yojMlbohsOtgB2docCsZk8UPqEbPVTizV--rMs",
"user": {
"_id": "62413827f85e740dd8af749a",
"email": "[email protected]",
"password": "hello",
"phone": "01723456789",
"createdAt": "2022-03-28T04:23:03.334Z",
"updatedAt": "2022-03-28T04:23:03.334Z",
"__v": 0
},
"createdAt": "2022-03-28T04:23:03.348Z",
"updatedAt": "2022-03-28T04:23:03.348Z",
"__v": 0
}
How can I get the value of "email" from "user" in flutter? I am using the following code.
http
.post(Uri.parse(url),
headers: {"Content-type": "application/json;charset=UTF-8"},
body: jsonEncode(model))
.then((value) {
var access = jsonDecode(value.body);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先你应该使用 model 。不使用模型它会帮助你
这只是一个例子如何从地图获取值
这里jsonDecode接受字符串值所以我这样做
first you should use model . without using model it will help you
it's only a example how to get value from map
here jsonDecode accept string value so i did this way