简体   繁体   English

获取Json输出,使用REST PHP显示在php中

[英]Getting Json output, display in php USING REST PHP

I have written Rest Api in python. 我用Python写了Rest Api。 and output comes in json format. 输出为json格式。

Like http://api.myserver.com/v0/movies http://api.myserver.com/v0/movies

it will give me output in json format: 它会以json格式输出:

[
{"id":"1","movie_name":"Toy story","genre":["children","action"]},
{{"id":"2","movie_name":"Jab tak hai jaan","genre":["romance","Drama"]}}
]

Now I want output in readable format using PHP. 现在,我想使用PHP以可读格式输出。

I heard that there is some concept of REST php. 我听说有一些REST php概念。 Which get output and store it in $rest variable and after that we can use it . 哪个获取输出并将其存储在$ rest变量中,之后我们就可以使用它了。 So can somebody tell me how to do this problem. 所以有人可以告诉我该怎么做。

Thanks. 谢谢。

use json_decode($json_string, true); 使用json_decode($json_string, true); which will give you array 这会给你数组

use 采用

json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]]

$json - is your json string $ json-是您的json字符串

$assoc = When TRUE, returned objects will be converted into associative arrays. $ assoc =为TRUE时,返回的对象将转换为关联数组。

documentation here 这里的文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM