PHP json解码器字符串

时间:2018-03-12 14:39:28

标签: php json

任何人都可以帮忙解码这个吗?

的var_dump

../fast-export-master/hg-fast-export.sh -r "D:\MyProject"

我需要获得"数据"从这段代码。

2 个答案:

答案 0 :(得分:1)

<?php
$data='{"success":{"message":"PDF \u0444\u0430\u0439\u043b\u0430 \u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e!","name":"invoice-0000000001.pdf","data":"JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7\/BCQEMAQ6BEIEQwRABDAAICEWADAAMAAwADAAMAAwADAAMA","type":"application\/pdf"}}';


$data=json_decode($data,true);
echo '<pre>';
print_r($data['success']['data']);

这是一个简单的json,你需要使它成为一个数组并将其作为普通数组访问。输出是您询问的数据字段:

JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7/BCQEMAQ6BEIEQwRABDAAICEWADAAMAAwADAAMAAwADAAMA

答案 1 :(得分:0)

嗯,你只需要<?php $input = '{"success":{"message":"PDF \u0444\u0430\u0439\u043b\u0430 \u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0430\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e!","name":"invoice-0000000001.pdf","data":"JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7\/BCQEMAQ6BEIEQwRABDAAICEWADAAMAAwADAAMAAwADAAMA","type":"application\/pdf"}}'; $output = json_decode($input); print_r($output->success->data); 那个字符串,你就得到了结果:

$args = array( 
    'parent'        => 0, 
    'hide_empty'    => 0
);
$all_cats = get_categories( $args );
echo count( $all_cats );
  

JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7 / BCQEMAQ6BEIEQwRABDAAICEWADAAMAAwADAAMAAwADAAMA