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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 为什么出现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 ...

  4. 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 = ' ...

  5. 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; ...

  6. Json解析报错: Error is : Unescaped control character...的解决方法

    在利用json-framework来实现json解析的过程时,会出现"-JSONValue Failed. Error is : Unescaped control character&qu ...

  7. Spring MVC 返回json数据 报406错误 问题解决方案

    将jackson jar包改为jackson-databind-2.5.0.jar  jackson-core-2.5.0.jar  jackson-annotations-2.5.0.jar(这个版 ...

  8. 商城项目,java返回json数据,报错406

    前言: 项目结构为maven,搭建好架构,整合ssm,进行测试, 从数据库中查询数据,返回json数据,结果报错406 问题: 解决: 1,确定项目中json包是否存在(极大可能出于此) 2,处理器适 ...

  9. iOS 后台返回json解析出现的null的解决办法

    在后台返回值为Null为空时,我们代码没有判断时,程序就会崩溃.当时一直很疑惑是为啥,后来发现是数据问题,由于服务器的数据库中有些字段为空,然后以Json形式返回给客户端时就会出现这样的数据.当我们通 ...

随机推荐

  1. Oracle SQL 基础学习

    oracel sql 基础学习 CREATE TABLE USERINFO ( ID ,) PRIMARY KEY, USERNAME ), USERPWD ), EMAIL ), REDATE DA ...

  2. 关于ContentProvider的批量操作

    今天看公司代码,发现在批量插入通话记录和联系人的时候,用了一个 ArrayList<ContentProviderOperation> ops = new ArrayList<Con ...

  3. python杂乱有关类与对象

    在python的类中,一般里面的方法和属性默认都是publlic,如果要设为private,即自己访问,主要是根据命名方式来区分的,通过__  两个下划线加在名字前面,即为私有方法和私有属性 构造方法 ...

  4. 那天有个小孩跟我说LINQ(一) 转载

    1  LINQ准备(代码下载) 新建项目 linq_Ch1控制台程序,新建一个Entity文件夹     1.1 对象初始化器     在Entity新建一个类Student,代码如下 using S ...

  5. httphandler与httpmodule区别

    1.配置不同: <httpModules> <!--name表示类名,BtEd2k.UILogic表示命名空间--> <add name="Common&quo ...

  6. Mysql笔记【2】-数据表的基本操作

    1.创建数据库表 create table <表名> ( 字段名1 类型 <列级别限制> , 字段名2 类型 <列级别限制> , 字段名3 类型 <列级别限制 ...

  7. 04_XML_04_XMLDTD语法

    [DTD语法约束细节] * 元素定义 * 属性定义 * 实体定义 [1.元素定义] 在DTD文档中使用ELEMENT声明一个XML元素,语法格式如下所示: <!ELEMENT   元素名称  元 ...

  8. leetcode344——Reverse String(C++)

    Write a function that takes a string as input and returns the string reversed. Example:Given s = &qu ...

  9. Python之实现一个简易计算器

    自己动手写计算器 一.功能分析 用户输入一个类似这样 3*( 4+ 50 )-(( 100 + 40 )*5/2- 3*2* 2/4+9)*((( 3 + 4)-4)-4) 这样的表达式,假设表达式里 ...

  10. centos 安装php-fpm , nginx二级域名配置 ,但为什么必须要 域名提供商 哪里解析新的二级域名一下 才能用呢?

    yum -y install php-fpm php-mysql(当然还有其它扩展) /etc/init.d/php-fpm restart (重启php-fpm) /etc/php.ini (php ...