php 返回json 解析 报Wide character in print
php 返回json:
zabbix:/var/www/html/DEVOPS/Home/Lib/Action# vim EquipmentAction.class.php <?php
header('Content-Type:application/json; charset=utf-8'); ##返回json php文件格式为utf-8 无BOM格式 public function search_ipadd(){
$where['ip'] = $_GET['ip'];
$Machine = M('Machine_info');
$arr = $Machine->where($where)->select();
echo json_encode($arr);
} public function search_ipadd(){
$where['ip'] = $_GET['ip'];
$Machine = M('Machine_info');
$arr = $Machine->where($where)->select();
$str= json_encode($arr);
echo preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $str); } echo preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $str); 解决返回[{"sn":"83","ip":"192.168.11.187","info":"ftp\u670d\u52a1\u5668","env":"esx-192.168.4.44"}] /***************************************************************************** centos6.5:/root#cat a1.pl
use Net::SMTP;
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Headers;
use HTTP::Response;
use Encode;
use JSON;
use File::Temp qw/tempfile/;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);
use Data::Dumper;
my $CurrTime = time2iso(time());
my $dis_mainpublish='中均资本';
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $now = time();
$ua->agent('Mozilla/5.0');
my $cookie_jar = HTTP::Cookies->new( file => 'lwp_cookies.txt',
autosave => 1,
ignore_discard => 1
);
$ua->cookie_jar($cookie_jar);
my $response = $ua->get("http://192.168.11.186/DEVOPS/index.php/Equipment/search_ipadd?ip=192.168.11.187"); if ($response->is_success) {
$r = $response->decoded_content;
print "\n"; }
else
{
die $response->status_line; };
print $r;
#my $r=encode_utf8($r);
my $hash = decode_json($r);
print "\n";
print $hash->[0]->{info};
print "\n";
centos6.5:/root#perl a1.pl [{"sn":"83","ip":"192.168.11.187","info":"ftp服务器","env":"esx-192.168.4.44"}]
Wide character in print at a1.pl line 38.
ftp服务器 解决 Wide character in print at a1.pl line 38. centos6.5:/root#vim a1.pl
centos6.5:/root#cat a1.pl
use Net::SMTP;
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Headers;
use HTTP::Response;
use Encode;
use JSON;
use File::Temp qw/tempfile/;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);
use Data::Dumper;
my $CurrTime = time2iso(time());
my $dis_mainpublish='中均资本';
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $now = time();
$ua->agent('Mozilla/5.0');
my $cookie_jar = HTTP::Cookies->new( file => 'lwp_cookies.txt',
autosave => 1,
ignore_discard => 1
);
$ua->cookie_jar($cookie_jar);
my $response = $ua->get("http://192.168.11.186/DEVOPS/index.php/Equipment/search_ipadd?ip=192.168.11.187"); if ($response->is_success) {
$r = $response->decoded_content;
print "\n"; }
else
{
die $response->status_line; };
print $r;
my $r=encode_utf8($r);
my $hash = decode_json($r);
print "\n";
print $hash->[0]->{info};
print "\n";
centos6.5:/root#
centos6.5:/root#perl a1.pl [{"sn":"83","ip":"192.168.11.187","info":"ftp服务器","env":"esx-192.168.4.44"}]
ftp服务器php 返回json 解析 报Wide character in print的更多相关文章
- Wide character in print at a2.pl line 返回json 需要encode_utf8
centos6.5:/root/test#cat a2.pl use Net::SMTP; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Heade ...
- Wide character in print at hcp.pl line 21.
jrhmpt01:/root# cat -n hcp.pl 1 use LWP::UserAgent; 2 use Encode; 3 $ua = LWP::UserAgent->new; 4 ...
- 为什么出现Wide character in print at a14.pl line 41
[root@wx03 ~]# cat a14.pl use Net::SMTP; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Headers; u ...
- perl unload utf-8 oracle Wide character in print at unload_oracle.pl line 105.
#!/usr/bin/perl use DBI; use Encode; my $dbName = 'oadb'; my $dbUser = 'vxspace'; my $dbUserPass = ' ...
- Wide character in print at a2.pl line 6.
jrhapt01:/home/tomcat/test> cat a2.pl my $str="$ARGV[0]"; use Encode; use URI::Escape; ...
- Json解析报错: Error is : Unescaped control character...的解决方法
在利用json-framework来实现json解析的过程时,会出现"-JSONValue Failed. Error is : Unescaped control character&qu ...
- Spring MVC 返回json数据 报406错误 问题解决方案
将jackson jar包改为jackson-databind-2.5.0.jar jackson-core-2.5.0.jar jackson-annotations-2.5.0.jar(这个版 ...
- 商城项目,java返回json数据,报错406
前言: 项目结构为maven,搭建好架构,整合ssm,进行测试, 从数据库中查询数据,返回json数据,结果报错406 问题: 解决: 1,确定项目中json包是否存在(极大可能出于此) 2,处理器适 ...
- iOS 后台返回json解析出现的null的解决办法
在后台返回值为Null为空时,我们代码没有判断时,程序就会崩溃.当时一直很疑惑是为啥,后来发现是数据问题,由于服务器的数据库中有些字段为空,然后以Json形式返回给客户端时就会出现这样的数据.当我们通 ...
随机推荐
- 抓取Bing每日图片作为网站首页背景
把Bing搜索的背景图片设置为自己网站的背景,实现背景及资讯的每日更新 效果图如下: 理一下思路,首先我们要抓取Bing的每日图片及最新资讯,然后保存图片及信息到本地,最后显示图片及资讯到网站首页. ...
- C# 简单的图像边缘提取
博主做的很简单,大家看一看就好了...... 用到的算法是robert算子,这是一种比较简单的算法: f(x,y)=sqrt((g(x,y)-g(x+1,y+1))^2+(g(x+1,y)-g(x,y ...
- javascript在html中使用 第10节
javascript在html中使用 index.html: <html> <head> <title>javascript</title> <s ...
- (转)Libevent(3)— 基础库
转自:http://name5566.com/4202.html 参考文献列表:http://www.wangafu.net/~nickm/libevent-book/ 此文编写的时候,使用到的 Li ...
- Oracle的硬解析和软解析
提到软解析(soft prase)和硬解析(hard prase),就不能不说一下Oracle对sql的处理过程.当你发出一条sql语句交付Oracle,在执行和获取结果前,Oracle对此sql将进 ...
- 使用JS实现鼠标滚轮事件
网站需要实现鼠标滚轮滚一下,页面向下滑向下一个锚点,由于前面有个一样式必须用jQuery1.3.2,而好多滚轮事件都使用了更高版本的jQuery,于是就从网上找了找 <script type=& ...
- 尝试使用Java6API读取java代码
主要类:JavaCompiler FileManager JavaCompiler .CompilationTaskAbstractProcessor参考代码https://today.java.n ...
- linux curl命令验证服务器断点续传支持
有个同事说,发现现在对外下载安装包的服务器不支持断点续传,我听了一阵纳闷,lighttpd server对于静态文件应该默认支持断点续传的,登机器查看lighttpd配置文件发现 对断点续传的支持被禁 ...
- REST API之前端跨域访问
关键字:跨域访问,cross-origin, NodeJS, REST API, JavaScript, Access-Control-Allow-Origin 1.新建并运行一个 NodeJS的se ...
- 使用South时候由于两个相同id的文件引起的问题
由于之前版本控制的一个小失误, 在主分子上面调用python manage.py makemigrations生成了 0058_auto__add_unique_setting_name_value. ...