草庐IT

day33-JSON

全部标签

c# - 从基于 JSON/PHP (base64_encode) 的图像中解释 C# 中的 base 64

所以我能够成功读取图像文件,并将其传回我的C#应用程序,但我无法正确解码它。我正在通过PHP返回JSON数据(未显示json_encode函数):$imgbinary=fread(fopen($filename,"r"),filesize($filename));if(strlen($imgbinary)>0){returnarray("success"=>true,"map"=>base64_encode($imgbinary));}然后在C#中,我使用Newtonsoft.Json解码字符串(我可以成功读取和map属性),但我无法使用base64解码将图像正确写入文件(或显示).我

php - Json eval 无法解析数据

我有一个php程序,我只在其中测试一些示例数据。我收到错误消息,因为元素列表后缺少]。我该如何阅读?$dataDetailsList=array();array_push($dataDetailsList,array('a'=>'1','b'=>'2','c'=>'3','d'=>'4','e'=>'5'));echojson_encode(array("DataDetailsList"=>$dataDetailsList));然后在我的jQuery处理器中我这样做。functionrequestData(){$.ajax({url:'live-server-data.php',suc

php - json_encode bool 返回错误值

我正在编写一个jquery登录。如果php登录脚本(checklogin.php)回显“true”,那么我的jquery页面应该发出警报。当我运行login.php(不使用jquery)时,它会将请求发送到checklogin.php,回显“true”,但是如果我使用我的jquery登录脚本将登录信息发送到checklogin.php,我跟踪的警报后面说“假”。$('#login').click(function(e){$.getJSON("http://www.hedonsoft.com/game/login.php",{username:$("#username").val(),p

php - 将数组从 json 解码为 PHP,但无法使用键访问数组元素

我有一些类似于以下的JSON:{"internalArray":{"201":"A","202":"B","5":"C","46":"D"},"data":"ABCDEFG","data2":"TSXPIIF"}我使用以下PHP代码对其进行解码:$jsonOutput=json_decode($output);我想从JSON数据访问“internalArray”,因此我使用以下方式引用它:$internalArray=$jsonOutput->{'internalArray'};当我对$internalArray执行var_dump时object(stdClass)#4(4){["20

php - 在 PHP 中通过 JSON API 获取 Youtube 订阅者数量

我想从这个JSON文件中获取订阅者计数值:http://gdata.youtube.com/feeds/api/users/googlechrome?v=2&alt=json这就是我所做的,但它不起作用。$youtube_url=json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/users/googlechrome?v=2&alt=json'),true);$youtube_data=$youtube_url['entry']['yt$statistics']['subscriberCount'];

php - 将数组数据作为对象附加到 json 文件

我有一个简单的json文件,它有一个直接图像链接和每个json对象的文件夹名称:[{"image":"http://placehold.it/350x150","folder":"Small"},{"image":"http://placehold.it/450x250","folder":"Medium"},{"image":"http://placehold.it/550x350","folder":"Medium"}]我想从帖子中附加这两个值,但结果是一个未更改的json文件。这是带有注释的PHP代码:$directLink=$_POST['txtDirectLink'];$ca

php - 修改 JSON 数据格式以用于 FLOT 图表

我正在尝试创建一个JSON对象来保存用于FLOT的数据图表。文档说数据格式应该是这样的点数组:[[1,3],[2,14.01],[3.5,3.14]]我遇到的问题是我的AJAX调用返回一个数据格式如下的JSON对象:Rate:[96,74,73,96,124,104]Year:[2008,2009,2010,2011,2012,2013]有人可以解释我应该如何修改这段代码,以便它创建FLOT图表所需的正确数据格式吗?谢谢。functionajaxmuniChart1c(){$muni=$this->input->POST('muni');$q=$this->db->query("SEL

PHP:如何从字符串转储中提取 JSON 字符串

我有一个巨大的字符串转储,其中混合了常规文本和JSON。我想从字符串转储中分离/删除JSON对象并仅获取文本。这是一个例子:Thisissometext{'JSON':'Object'}Here'ssomemoretext{'JSON':'Object'}Yetmoretext{'JSON':'Object'}Again,sometext.我的目标是获得如下所示的文本转储(基本上删除了JSON):ThisissometextHere'ssomemoretextYetmoretextAgain,sometext.我需要用PHP完成这一切。文本转储总是随机的,JSON数据结构也是如此(其中

php - 使用 Laravel 从数组中获取 JSON 值

我正在尝试从JSON数组获取纬度和经度值-$response,从Google的地理编码服务返回。JSON数组原样返回(随机地址):{"results":[{"address_components":[{"long_name":"57","short_name":"57","types":["street_number"]},{"long_name":"PoloGardens","short_name":"PoloGardens","types":["route"]},{"long_name":"Bucksburn","short_name":"Bucksburn","types":["

php - json_decode 为 WordPress 中的 POST 数据返回 "NULL"

我尝试像这样JSON.stringify一个数组到服务器:JavaScript:jQuery.ajax({type:'post',url:ajax_url,data:{'settings':JSON.stringify([...]),'action':[...]},traditional:true,success:function(data){alert("SUCCESS");},error:function(errorThrown){console.log(errorThrown);}});但是当我在PHP中尝试json_encode时,它返回NULL。PHP$param=json_