- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我的 Zend_Json 在编码一个对象时搞砸了。我正在编码一个包含两个元素的关联数组:元素 1 是另一个关联数组,而元素 2 是 HTML 字符串。他搞砸了,以至于 Html 字符串部分只包含 NULL!!?!?!?!?
当我对它执行 var_dump 时,这是未编码的元素...抱歉元素太长了...它非常不稳定 - 我不明白这里出了什么问题......
array (
'map' =>
array (
0 =>
array (
'id' => '1403',
'name' => 'Amborovy Airport (Philibert Tsiranana Airport)',
'label' => 'Amborovy Airport (Philibert Tsiranana Airport)',
'html' => 'Amborovy Airport (Philibert Tsiranana Airport)',
'lat' => '-0.666944',
'lng' => '46.3517',
),
1 =>
array (
'id' => '6160',
'name' => 'Generalissimo Francisco de Miranda Airbase',
'label' => 'Generalissimo Francisco de Miranda Airbase',
'html' => 'Generalissimo Francisco de Miranda Airbase',
'lat' => '0.485',
'lng' => '-66.8436',
),
2 =>
array (
'id' => '7808',
'name' => 'Tirana International Airport',
'label' => 'Tirana International Airport',
'html' => 'Tirana International Airport',
'lat' => '41.4150929722',
'lng' => '19.7233001667',
),
3 =>
array (
'id' => '20881',
'name' => 'Tiranë Heliport',
'label' => 'Tiranë Heliport',
'html' => 'Tiranë Heliport',
'lat' => 41.315865416667,
'lng' => 19.888245972222,
),
4 =>
array (
'id' => '5218',
'name' => 'Abadan Airport',
'label' => 'Abadan Airport',
'html' => 'Abadan Airport',
'lat' => '0.371111',
'lng' => '48.2283',
),
5 =>
array (
'id' => '5330',
'name' => 'Lar Airport',
'label' => 'Lar Airport',
'html' => 'Lar Airport',
'lat' => '0.673056',
'lng' => '54.3814',
),
6 =>
array (
'id' => '7808',
'name' => 'Tirana International Airport',
'label' => 'Tirana International Airport',
'html' => 'Tirana International Airport',
'lat' => '41.4150929722',
'lng' => '19.7233001667',
),
7 =>
array (
'id' => '20881',
'name' => 'Tiranë Heliport',
'label' => 'Tiranë Heliport',
'html' => 'Tiranë Heliport',
'lat' => 41.315865416667,
'lng' => 19.888245972222,
),
8 =>
array (
'id' => '5218',
'name' => 'Abadan Airport',
'label' => 'Abadan Airport',
'html' => 'Abadan Airport',
'lat' => '0.371111',
'lng' => '48.2283',
),
9 =>
array (
'id' => '5225',
'name' => 'Ahvaz Airport',
'label' => 'Ahvaz Airport',
'html' => 'Ahvaz Airport',
'lat' => '0.337431',
'lng' => '48.762',
),
10 =>
array (
'id' => '5242',
'name' => 'Ardabil Airport',
'label' => 'Ardabil Airport',
'html' => 'Ardabil Airport',
'lat' => '0.325556',
'lng' => '48.4242',
),
11 =>
array (
'id' => '5243',
'name' => 'Asalouyeh Airport',
'label' => 'Asalouyeh Airport',
'html' => 'Asalouyeh Airport',
'lat' => '0.481389',
'lng' => '52.6153',
),
12 =>
array (
'id' => '5251',
'name' => 'Bandar Abbas International Airport',
'label' => 'Bandar Abbas International Airport',
'html' => 'Bandar Abbas International Airport',
'lat' => '0.218056',
'lng' => '56.3778',
),
13 =>
array (
'id' => '5259',
'name' => 'Birjand Airport',
'label' => 'Birjand Airport',
'html' => 'Birjand Airport',
'lat' => '0.898056',
'lng' => '59.2661',
),
14 =>
array (
'id' => '5278',
'name' => 'Dezful Airport',
'label' => 'Dezful Airport',
'html' => 'Dezful Airport',
'lat' => '0.434444',
'lng' => '48.3976',
),
15 =>
array (
'id' => '5306',
'name' => 'Jiroft Airport',
'label' => 'Jiroft Airport',
'html' => 'Jiroft Airport',
'lat' => '0.726944',
'lng' => '57.6703',
),
16 =>
array (
'id' => '5326',
'name' => 'Konarak Airport',
'label' => 'Konarak Airport',
'html' => 'Konarak Airport',
'lat' => '0.443333',
'lng' => '60.3819',
),
17 =>
array (
'id' => '5330',
'name' => 'Lar Airport',
'label' => 'Lar Airport',
'html' => 'Lar Airport',
'lat' => '0.673056',
'lng' => '54.3814',
),
18 =>
array (
'id' => '5331',
'name' => 'Lavan Airport',
'label' => 'Lavan Airport',
'html' => 'Lavan Airport',
'lat' => '0.810278',
'lng' => '53.3561',
),
19 =>
array (
'id' => '5359',
'name' => 'Parsabad-Moghan Airport',
'label' => 'Parsabad-Moghan Airport',
'html' => 'Parsabad-Moghan Airport',
'lat' => '0.603606',
'lng' => '47.8815',
),
20 =>
array (
'id' => '5361',
'name' => 'Persian Gulf Airport (Khalije Fars Airport)',
'label' => 'Persian Gulf Airport (Khalije Fars Airport)',
'html' => 'Persian Gulf Airport (Khalije Fars Airport)',
'lat' => '0.379444',
'lng' => '52.7375',
),
21 =>
array (
'id' => '5393',
'name' => 'Shahid Sadooghi Airport',
'label' => 'Shahid Sadooghi Airport',
'html' => 'Shahid Sadooghi Airport',
'lat' => '0.905',
'lng' => '54.2764',
),
22 =>
array (
'id' => '5411',
'name' => 'Tabriz International Airport',
'label' => 'Tabriz International Airport',
'html' => 'Tabriz International Airport',
'lat' => '0.133889',
'lng' => '46.235',
),
23 =>
array (
'id' => '1416',
'name' => 'Arrachart Airport',
'label' => 'Arrachart Airport',
'html' => 'Arrachart Airport',
'lat' => '-0.349167',
'lng' => '49.2917',
),
24 =>
array (
'id' => '7808',
'name' => 'Tirana International Airport',
'label' => 'Tirana International Airport',
'html' => 'Tirana International Airport',
'lat' => '41.4150929722',
'lng' => '19.7233001667',
),
25 =>
array (
'id' => '20881',
'name' => 'Tiranë Heliport',
'label' => 'Tiranë Heliport',
'html' => 'Tiranë Heliport',
'lat' => 41.315865416667,
'lng' => 19.888245972222,
),
),
'html' => '<div><b>Search Results for terms \'Iran\'</b> </div><a class="map-link" href="javascript:void(0);" onclick="toggleMapsSearch(\'name\');">4 results of Names with "Iran"</a><div id="map-results-name" class="map-results-nubbin" style="display:none;"><a class="map-sub-links" href="javascript:mapClickHandler(\'1403\')">Amborovy Airport (Philibert Ts<span Style="color:red; Font-weight:bold;">Iran</span>ana Airport)</a><a class="map-sub-links" href="javascript:mapClickHandler(\'6160\')">Generalissimo Francisco De M<span Style="color:red; Font-weight:bold;">Iran</span>da Airbase</a><a class="map-sub-links" href="javascript:mapClickHandler(\'7808\')">T<span Style="color:red; Font-weight:bold;">Iran</span>a International Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'20881\')">T<span Style="color:red; Font-weight:bold;">Iran</span>ë Heliport</a></div><a class="map-link" href="javascript:void(0);" onclick="toggleMapsSearch(\'city\');">4 results of Cities with "Iran"</a><div id="map-results-city" class="map-results-nubbin" style="display:none;"><a class="map-sub-links" href="javascript:mapClickHandler(\'5218\')">Abadan, <span Style="color:red; Font-weight:bold;">Iran</span> : Abadan Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5330\')">Lar, <span Style="color:red; Font-weight:bold;">Iran</span> : Lar Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'7808\')">T<span Style="color:red; Font-weight:bold;">Iran</span>a : Tirana International Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'20881\')">T<span Style="color:red; Font-weight:bold;">Iran</span>a : Tiranë Heliport</a></div><a class="map-link" href="javascript:void(0);" onclick="toggleMapsSearch(\'country\');">15 results of Countries with "Iran"</a><div id="map-results-country" class="map-results-nubbin" style="display:none;"><a class="map-sub-links" href="javascript:mapClickHandler(\'5218\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Abadan Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5225\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Ahvaz Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5242\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Ardabil Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5243\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Asalouyeh Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5251\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Bandar Abbas International Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5259\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Birjand Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5278\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Dezful Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5306\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Jiroft Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5326\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Konarak Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5330\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Lar Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5331\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Lavan Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5359\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Parsabad-Moghan Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5361\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Persian Gulf Airport (Khalije Fars Airport)</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5393\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Shahid Sadooghi Airport</a><a class="map-sub-links" href="javascript:mapClickHandler(\'5411\')"><span Style="color:red; Font-weight:bold;">Iran</span> : Tabriz International Airport</a></div>',
)
下面是当我尝试使用 Zends_JSON 类将其编码为 JSON 时发生的情况...
{"map":[{"id":"1403","name":"Amborovy Airport (Philibert Tsiranana Airport)","label":"Amborovy Airport (Philibert Tsiranana Airport)","html":"Amborovy Airport (Philibert Tsiranana Airport)","lat":"-0.666944","lng":"46.3517"},{"id":"6160","name":"Generalissimo Francisco de Miranda Airbase","label":"Generalissimo Francisco de Miranda Airbase","html":"Generalissimo Francisco de Miranda Airbase","lat":"0.485","lng":"-66.8436"},{"id":"7808","name":"Tirana International Airport","label":"Tirana International Airport","html":"Tirana International Airport","lat":"41.4150929722","lng":"19.7233001667"},{"id":"20881","name":null,"label":null,"html":null,"lat":41.315865416667,"lng":19.888245972222},{"id":"5218","name":"Abadan Airport","label":"Abadan Airport","html":"Abadan Airport","lat":"0.371111","lng":"48.2283"},{"id":"5330","name":"Lar Airport","label":"Lar Airport","html":"Lar Airport","lat":"0.673056","lng":"54.3814"},{"id":"7808","name":"Tirana International Airport","label":"Tirana International Airport","html":"Tirana International Airport","lat":"41.4150929722","lng":"19.7233001667"},{"id":"20881","name":null,"label":null,"html":null,"lat":41.315865416667,"lng":19.888245972222},{"id":"5218","name":"Abadan Airport","label":"Abadan Airport","html":"Abadan Airport","lat":"0.371111","lng":"48.2283"},{"id":"5225","name":"Ahvaz Airport","label":"Ahvaz Airport","html":"Ahvaz Airport","lat":"0.337431","lng":"48.762"},{"id":"5242","name":"Ardabil Airport","label":"Ardabil Airport","html":"Ardabil Airport","lat":"0.325556","lng":"48.4242"},{"id":"5243","name":"Asalouyeh Airport","label":"Asalouyeh Airport","html":"Asalouyeh Airport","lat":"0.481389","lng":"52.6153"},{"id":"5251","name":"Bandar Abbas International Airport","label":"Bandar Abbas International Airport","html":"Bandar Abbas International Airport","lat":"0.218056","lng":"56.3778"},{"id":"5259","name":"Birjand Airport","label":"Birjand Airport","html":"Birjand Airport","lat":"0.898056","lng":"59.2661"},{"id":"5278","name":"Dezful Airport","label":"Dezful Airport","html":"Dezful Airport","lat":"0.434444","lng":"48.3976"},{"id":"5306","name":"Jiroft Airport","label":"Jiroft Airport","html":"Jiroft Airport","lat":"0.726944","lng":"57.6703"},{"id":"5326","name":"Konarak Airport","label":"Konarak Airport","html":"Konarak Airport","lat":"0.443333","lng":"60.3819"},{"id":"5330","name":"Lar Airport","label":"Lar Airport","html":"Lar Airport","lat":"0.673056","lng":"54.3814"},{"id":"5331","name":"Lavan Airport","label":"Lavan Airport","html":"Lavan Airport","lat":"0.810278","lng":"53.3561"},{"id":"5359","name":"Parsabad-Moghan Airport","label":"Parsabad-Moghan Airport","html":"Parsabad-Moghan Airport","lat":"0.603606","lng":"47.8815"},{"id":"5361","name":"Persian Gulf Airport (Khalije Fars Airport)","label":"Persian Gulf Airport (Khalije Fars Airport)","html":"Persian Gulf Airport (Khalije Fars Airport)","lat":"0.379444","lng":"52.7375"},{"id":"5393","name":"Shahid Sadooghi Airport","label":"Shahid Sadooghi Airport","html":"Shahid Sadooghi Airport","lat":"0.905","lng":"54.2764"},{"id":"5411","name":"Tabriz International Airport","label":"Tabriz International Airport","html":"Tabriz International Airport","lat":"0.133889","lng":"46.235"},{"id":"1416","name":"Arrachart Airport","label":"Arrachart Airport","html":"Arrachart Airport","lat":"-0.349167","lng":"49.2917"},{"id":"7808","name":"Tirana International Airport","label":"Tirana International Airport","html":"Tirana International Airport","lat":"41.4150929722","lng":"19.7233001667"},{"id":"20881","name":null,"label":null,"html":null,"lat":41.315865416667,"lng":19.888245972222}],"html":null}
注意最后 - HTML 的巨大笨拙 - GONE 被 null 取代......这里发生了什么:(
编辑
经过一些调查,我在错误日志中发现了这个错误:
PHP Warning: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument in C:\wamp\www\fltdata\library\Zend\Json.php
我认为这可能与我面临的问题有关?我该如何解决这个问题?
编辑
我的 Php 版本是 5.2.9-2 - 我怀疑这是由于早于 5.2.7 的版本中存在的问题...请大家帮忙!!!
编辑
通过 json_encode() 运行对象返回相同的结果,我得到相同的错误:
PHP Warning: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument in...
我在这里难住了:(
解决方案
呜呼!!!!我想通了:我只是通过 utf8_encode 函数运行 html 字符串变量,然后在其上运行 JSON 编码函数:
$result['html'] = utf8_encode($result['html']);
它有效 - 感谢大家的所有帮助 - 我无法为这里的每个帖子投票超过一次,这让我感到非常局限 - 你们都是非常棒的帮助 :D 再次感谢!!!
最佳答案
您可以通过将 PHP 版本更新到高于 5.2.7 的版本来解决此问题。
有一个serious UTF-8 bug在 PHP 的 json_encode 中该版本之前的功能。查看changelog了解更多详情。
既然您注意到您使用的是 PHP 版本 5.2.9.2,那么您的版本应该不错 :) 您是否尝试过手动通过 PHP 的 json_encode() 路由 html 的特定内容?
或者可能通过 utf8_encode()或 utf8_decode() ?
关于php - Zend_JSON :Encode messing up - why?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1741894/
所以...这是我第一次弄乱函数,几乎从未使用过 for ,我想创建一个函数,它打印 hello 的次数与参数 ( n) 表示。 #include int say_hello(int n){
今天早上我陷入了困境,不得不创建一个分支来恢复到我上次提交的状态。现在 master 分支一团糟,我唯一感兴趣的是这个带有恢复的新分支。我如何强制 master 与还原的分支相同? 最佳答案 git
我对 C++ 的内部工作原理有一些疑问。例如,我知道一个类的每个成员函数都有一个隐含的隐藏参数,即 this 指针(与 Python 的做法非常相似): class Foo { Foo(con
我试图在不同的类上使用单独的 CSS LINK 样式。当我在链接上“悬停”时,链接会乱七八糟。我该如何解决这个问题,以便当我将鼠标悬停在链接上时不会显示不同的 css 样式? 这是相关的 CSS。 .
我的 index.php 文件开头有这段代码: if ( !isset($_GET['cat']) ) die(header("Location: ?cat=top")
我的 Zend_Json 在编码一个对象时搞砸了。我正在编码一个包含两个元素的关联数组:元素 1 是另一个关联数组,而元素 2 是 HTML 字符串。他搞砸了,以至于 Html 字符串部分只包含 NU
我是一名编码员(我使用的是 Mac),我使用的计算机是一台“不应该被弄乱”的计算机。我想安装一些命令行程序,但我希望能够以某种方式删除我所做的一切。 我知道,我不应该做任何以防万一的事情。 但是,我想
此代码旨在循环遍历所有结果页面,然后循环遍历每个页面上的结果表,并从表中抓取所有数据以及表外部存储的一些信息。 但是,生成的 CSV 文件似乎没有任何合理的组织,每行的不同列中都有不同类别的信息。我所
我是 SwipeListView 库的新手,当滑动列表项之一时,该功能的工作原理如下: 应用程序正在运行,但 View 困惑,以至于隐藏的内容(即滑动列表项后看到的内容)被覆盖在每个列表项的顶部。按照
在我做的元素中,我希望用户能够上传图片。这些图片必须按照从首次上传到最后上传的顺序排列。 看看下面的代码: body{ color:white; } #wrap{ margin-top:10px; o
我试图将搜索栏置于页脚的中央。使用以下解决方案后:[https://stackoverflow.com/questions/19733447/bootstrap-navbar-with-left-ce
我正在尝试将几个文件连接在一起并添加标题。 import subprocess outpath = "output.tab" with open( outpath, "w" ) as outf :
下面是我的 Debian Wheezy 工作站上 Oracle 的 JavaFX“Hello World”示例的屏幕截图的两个链接。 第一个是用 JDK6u67 和 1.7 目标构建的,并用相应的 J
在我的 iPhone 应用程序中,我使用 NSDecimalNumber 来存储一些货币汇率值。我在应用程序第一次启动时从网络上提取数据,然后在它们过时时再次提取数据,并将它们存储在 NSDictio
由于某种原因,我遇到了麻烦,但我似乎不知道如何解决...我正在做一个测验,它以开始按钮开始,并有“下一个”和“上一个”按钮。当我点击开始按钮时,问题 1 和答案 1 将会出现,开始按钮消失,当我然后点
我正在查看应用程序见解并调查性能问题: -> 应用程序洞察 -> 性能 -> 选择操作 -> 探查器跟踪 屏幕左侧该操作的持续时间为(7462.45 毫秒),而该操作的事件的总持续时间为(15509.
我正在查看应用程序见解并调查性能问题: -> 应用程序洞察 -> 性能 -> 选择操作 -> 探查器跟踪 屏幕左侧该操作的持续时间为(7462.45 毫秒),而该操作的事件的总持续时间为(15509.
我正在使用 java 泛型,我想避免类头中出现困惑。 // The car saves a generic list class Car{ ArrayList exampleList=new Arr
我只是在玩数组,我在 Emacs (OSX) 中编写了这个小东西,当我尝试运行它时遇到了 Bus error: 10。我不知道为什么会这样,也许有人可以告诉我... #include int mai
所以我在使用 jquery 放置悬停工具提示时遇到了一点问题 - 如果我的父 div 的 css 中的“位置”属性设置为“相对”,则工具提示会飞到屏幕的左上角。如果我删除 position 属性,那么
我是一名优秀的程序员,十分优秀!