Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json空对象请求输入与预期不符 #3116

Closed
LonelySally opened this issue Feb 17, 2025 · 1 comment
Closed

json空对象请求输入与预期不符 #3116

LonelySally opened this issue Feb 17, 2025 · 1 comment
Labels

Comments

@LonelySally
Copy link
Contributor

所属功能组件

请求(Request)

ThinkPHP 版本

8.x-dev

操作系统

Centos

错误信息

//Content-Type:application/json

{
    "rules": {
        "A": {},
        "B": []
    }
}

当请求内包含空对象时,会被统一解析成空数组导致与预期不符.

问题发上在Request.php处.

//得到结果
[
  +"A": []
  +"B": []
]

//预期得到
[
  +"A": {#329}
  +"B": []
]

其它说明

No response

@LonelySally
Copy link
Contributor Author

就该处改动已然不现实,框架对于入参的取值操作均为数组操作,变动量巨大,且不兼容.因此推荐单独获取原始入参处理.

 $data = json_decode(file_get_contents('php://input'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant