小编cas*_*per的帖子

如何处理作为HTTP Post发送到cakephp应用程序的json数据?

如果我发送一个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)

cakephp

6
推荐指数
2
解决办法
5986
查看次数

我可以参考defstruct中的其他插槽吗?

在常见的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)

有没有办法做到这一点?

common-lisp

4
推荐指数
1
解决办法
423
查看次数

标签 统计

cakephp ×1

common-lisp ×1