如何在PHP中解析JSON [英] How to parse JSON in PHP

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

问题描述

我正在尝试解析POST发送到我的Web服务的JSON. 我正在使用适用于Google Chrome的Advanced Rest Client工具来测试restapi.

I'm trying to parse JSON sent by POST to my webservice. I'm using Advanced Rest Client tool for Google Chrome to test restapi.

我如何阅读此请求并对其进行回复?

How can I read this request and response to it?

我正在发送称为格式"和"json"的密钥作为该密钥的值.我正在添加

I'm sending key called "format" and "json" as value for this key. I'm adding JSON like

"{"id":"235325"}"

我的PHP API代码的一部分:

Part of my PHP API code:

if( strcasecmp($format,'json') == 0 )
{
   //how to read that id = 235325?
}

推荐答案

尝试 json_decode() 功能.这是在php中解析json的标准功能.

Try the json_decode() function. It is the standard function to parse json in php.

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

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