通过json_decode来回显数据json [英] Echo data json by json_decode

查看:164
本文介绍了通过json_decode来回显数据json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过json_decode来回显json_encode值,怎么回事?

I want echo value json_encode by json_decode, how is it?

以下是我无法尝试的php代码:

Following php code is my try that not work:

$json = '[{"dg_j":"1390\/02\/05","dg_sh":"2011\/4\/25"}]';

$obj = json_decode($json);

echo $obj->{'dg_j'};
echo '<br>';
echo $obj->{'dg_sh'};

推荐答案

实际上,您得到的是一个包含单个对象的数组.你想要

What you've got is actually an array that contains a single object. You'd want

$obj[0]->dg_j

执行var_dump($obj)将显示JSON实际变成了什么.

Doing a var_dump($obj) will show you what the JSON actually turned into.

这篇关于通过json_decode来回显数据json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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