PHP解码JSON获取值 [英] php decode JSON get values

查看:78
本文介绍了PHP解码JSON获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解码JSON格式

I'm trying to decode JSON format

我发送的是:

{
"id": 123,
"name": "John",
"surname": "Smith",
"department": 3
}

我正在通过邮递员发送带有数据的POST,如图所示。

因此,这是我要解码的数据:

I am sending POST with data via Postman, in the picture.
So, this is the data I want to decode:

"data_serever_received": "{ \"id\": 123, \"name\": \"john\", "surname": "Smith", "department": 3 }"

我尝试过

$this->input->data["id"]

但它不起作用。

如何获取ID,名称,姓氏等值?

How can I get the id, name, surname and etc. values?

推荐答案

您的JSON无效 不是

Your JSON is invalid " and " are not ".

(如果看不到区别,请放大浏览器)。

(Zoom in with your browser if you can't see the difference).

您需要先使用有效的JSON进行解析。

You need to start with valid JSON before you can parse it.

这篇关于PHP解码JSON获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆