草庐IT

json_util

全部标签

php - 在数组的相同索引上使用 json 数据推送 id

我最近开始使用php处理json,现在我有一个json字符串存储在数据库中的联系表单表中,从数据库中检索的数据采用以下格式Array([0]=>Array([id]=>18[data]=>{"name":"asdsa","email":"uneebmir321@yahoo.com","phone":"1321","subject":"asdsadsa","message":"ssa"})[1]=>Array([id]=>19[data]=>{"name":"uneeb","email":"uneeb@nextcrawl.com","phone":"1232112","subject":

PHP 5 和 7 - json_last_error 区别

我正在尝试将我的一个PHP应用程序升级到PHP7。一切都很好,除了一个。我看到json_last_error()在PHP7中返回了不同的值。$input=file_get_contents('php://input');$json=json_decode($input,true);print_r(json_last_error());当我做curl'http://localhost/test.php'-H'Content-Type:application/json'--compressedPHP5返回0(JSON_ERROR_NONE)PHP7返回4(JSON_ERROR_SYNTAX

php - 如何用php将json数据转成html?

如何用php将json数据转成html?$url="http://api.nytimes.com/svc/search/v1/article?format=json&query=usa&rank=newest&api-key=mykey"当我在浏览器中输入url时,它返回{"offset":"0","results":[{"body":"Aguidetoculturalandrecreationalgoings-oninandaroundtheHudsonValley....}]}如何放置jsonbody数据转换成html?我的意思是这样echo''; 最佳

php - JSON -> PHP 数组,很难找到特定值的索引路径

我有一个JSON字符串,我已使用“json_decode”将其转换为关联的PHP数组。出于某种原因,我似乎无法弄清楚如何找到我在数组中查找的值的索引路径。这是JSON字符串:{"status":"OK","results":[{"types":["street_address"],"formatted_address":"175HemenwaySt,Boston,MA02115,USA","address_components":[{"long_name":"175","short_name":"175","types":["street_number"]},{"long_name":

php - "application/json"类型阻止发送后变量

我发现如果我尝试PHPPOSTcurl,postvars发送正常。一旦我添加了content-type:application/json的httpheader,postvars就不会再出现了。我尝试将postvars作为JSON字符串和查询字符串。显示一些代码:$ch=curl_init();$post=json_encode(array('p1'=>'blahblahblah','p2'=>json_encode(array(4,5,6))));$arr=array();array_push($arr,'Content-Type:application/json;charset=ut

php - 将 php session 变量序列化为 json 格式

我想通过jQuery访问PHPsession变量。这样做的最佳方法是什么? 最佳答案 尽管如此,请注意您在session中存储的内容。;) 关于php-将phpsession变量序列化为json格式,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/5374368/

php - 使用 getJSON 不显示 JSON 数据

$('document').ready(function(){$.getJSON('news.php',parseInfo);});functionparseInfo(data){alert(data.news);//undefined$('#info').html(data.news);}我的PHP输出(news.php)是[{"id":"20110428","news":"april282011"}] 最佳答案 您的对象被包裹在一个数组中。你需要data[0].news或者从您的JSON输出中删除外部方括号。

php - Google Dictionary API 的 json_decode

我正在尝试使用PHP解码GoogleDictionaryAPIJSON响应,但我遇到了似乎无法解析响应的问题(json_decode返回NULL).示例JSON响应位于here(搜索单词“oracle”)。JSONAPI要求你提交一个回调函数,所以我选择了很短的东西(a),因为它没有必要处理。这是我的代码: 最佳答案 Google以函数调用的形式返回结果。如果你想摆脱它,你可以这样做:所以你必须去掉那部分:$file=substr($file,2,-10);此外,所有的十六进制字符都会造成困惑。我不知道处理这些的最佳方式(他们应该转

php - 需要从 php json_encode 调用输出 javascript 日期对象

这个问题在这里已经有了答案:CanaJSONobjectreturnedbyPHPcontainadateobject(5个答案)关闭9年前。$array=array('start'=>"newDate(".date("Y",strtotime($start_date)).")");$myJson=json_encode($array);返回的json是字符串,如何将日期转换为对象?我正在使用jquery日历插件,它需要一个日期对象。谢谢!

php - json_encode 和波斯语单词?

我正在使用json_encode用于插入值数组(如:...在数据库中,不知道为什么它插入波斯语单词为["\u0633\u06cc\u062f\u0633\u0639\u06cc\u062f\u062f\u0627\u062f\u0627\u0634\u0632\u0627\u062f\u0647"]它之前插入为:سیدسعیدداداشزاده。数据库的输出(select*fromtabla...)byjson_encode是:[\"\\u0633\\u06cc\\u062f\\u0633\\u0639\\u06cc\\u062f\\u062f\\u0627\\u062f\\u0627