如果我发送一个HTTP POST在HTTP请求的主体仅仅是一个UTF8编码的字符串,我如何访问我的CakePHP控制器的数据?似乎$ this-> params只包含以下内容:
{
"pass":[],
"named":[],
"controller":"users",
"action":"checkin",
"plugin":null,
"url":{
"ext":"json",
"url":"users\/checkin.json"
},
"form":[],
"isAjax":false
}
Run Code Online (Sandbox Code Playgroud)
发布的数据看起来像这样:
{
"sessionkey":"somecrazykey",
"longitude":"-111.12345",
"latitude":"33.12345",
"reqtype":"checkin",
"location":"the mall",
"public":"true"
}
Run Code Online (Sandbox Code Playgroud) 在常见的lisp我注意到我可以这样写:
(defun foo (&key (a 1) (b 2) (c (+ a b))) (print (+ a b c)))
Run Code Online (Sandbox Code Playgroud)
当我打电话时(foo)
,6
打印出来.所以参数c
可以引用为a
和设置的值b
.但我似乎找不到办法做类似的事情defstruct
.就像是:
CL-USER> (defstruct thing a b c)
THING
CL-USER> (setq q (make-thing :a 1 :b 2 :c (+ a b)))
; Evaluation aborted
CL-USER> (setq q (make-thing :a 1 :b 2 :c (+ :a :b)))
; Evaluation aborted
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?