gpt4 book ai didi

json - Angular http.post 嵌套 json

转载 作者:行者123 更新时间:2023-12-02 09:14:38 26 4
gpt4 key购买 nike

我正在使用 Angular5 和 Symfony 3.4 以及 FOSUserBundle。

我有类似的东西:

register(username: string, email: string, first: string, second: string)
{
return this.appHttp.post('register', {username, email, first, second}).subscribe(
data => {
this.appHttp.logRequest(data);
}
);
}

我需要发送到 API 的是格式化的 json,如下所示:

{
"email": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f99c94989095b98d9c8a8dd79a9694" rel="noreferrer noopener nofollow">[email protected]</a>",
"username" : "userTest",
"plainPassword" : {
"first" : "123",
"second": "123"
}
}

目前,我的 json 看起来像:

{
"email": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="294c44484045695d4c5a5d074a4644" rel="noreferrer noopener nofollow">[email protected]</a>",
"username" : "userTest",
"first": "123",
"second": "123",
}

如何发布所需的 json ?

谢谢!

最佳答案

只需更改:

{username, email, first, second}

{username, email, plainPassword : {first, second} }

关于json - Angular http.post 嵌套 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48420764/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com