Heim  >  Fragen und Antworten  >  Hauptteil

php要如何获取json里面的值

我是一个php新手,现在在自己写一个简单的借口,在接口文件中返回一个json,
要怎么在另外一个文件中获取json里面的值,这个是我用curl获取到的json
{"key":"testAction","account":"root","weight":"200kg"}
然后我要怎么获取里面的值?比方说单单获取key或者account?
我用$jsContent.key和$jsContent["key"]都不行,要怎么处理这样子的数据,
也试过json_decode,也是不行

phpcn_u981phpcn_u9812790 Tage vor1379

Antworte allen(2)Ich werde antworten

  • 数据分析师

    数据分析师2017-10-01 00:35:40

    php要如何获取json里面的值-PHP中文网问答-php要如何获取json里面的值-PHP中文网问答

    围观一下哦,学习一下。

    Antwort
    0
  • 巴扎黑

    巴扎黑2017-03-01 09:52:32

    json_decode($data, TRUE); 第二个参数加上TRUE会把json数据转成PHP数组

    Antwort
    0
  • StornierenAntwort