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

    IEEE802.15.4定义了两种器件:全功能器件(FFD,Full-FunctionDevice),和简化功能器件(RFD,Reduced-functionDevice) 协调器:(coordina ...

  2. 通过Web.config中的configSections配置自己系统的全局常量

    通过Web.config中的configSections配置自己系统的全局常量 随着系统的庞大,你的全局信息保存在appsitting里可能会比较乱,不如为模块写个自定义的全局常量吧 首先在Web.C ...

  3. Jquery Ajax 调用 WebService

    原文:http://www.cnblogs.com/andiki/archive/2010/05/17/1737254.html jquery ajax调用webservice(C#)要注意的几个事项 ...

  4. SQL Server 表水平分区

    什么是表分区 一般情况下,我们建立数据库表时,表数据都存放在一个文件里. 但是如果是分区表的话,表数据就会按照你指定的规则分放到不同的文件里,把一个大的数据文件拆分为多个小文件,还可以把这些小文件放在 ...

  5. WPF简单拖拽功能实现

    1.拖放操作有两个方面:源和目标. 2.拖放操作通过以下三个步骤进行: ①用户单击元素,并保持鼠标键为按下状态,启动拖放操作. ②用户将鼠标移到其它元素上.如果该元素可接受正在拖动的内容的类型,鼠标指 ...

  6. Oracle的安装

    本人所使用的数据库平台为Oracle 11g 1.下载Oracle Oracle官网即可下载Oracle平台.不过网上资源丰富,大家也可在百度云网盘找到合适的版本. 附上本人网盘里存储的各个Oracl ...

  7. mongodb 安装及,设置账户、主从

    我原来没用过mongodb ,在晚上查了查需要的命令,关于怎么mongodb怎么用,我就不知道了 官方网站: http://www.mongodb.org/ MongoDB 安裝,主从配置一 Mong ...

  8. shell脚本操作mysql数据库—创建数据库,在该数据库中创建表(插入,查询,更新,删除操作也可以做)

    #!/bin/bash HOSTNAME="192.168.1.224"                                           #数据库Server信 ...

  9. web前端必须掌握的localStorage

    先自我介绍一下,本人男,27岁,单身,web前端程序员一枚,长期潜伏在幕后,只学不教(貔貅么?),其实主要是工作太忙了,每天忙到11点左右,没有时间写东西,洗洗就睡了.最近赶巧,后端那边出技术瓶颈了, ...

  10. js 作为属性的变量

    当声明一个javascript全局变量时,实际上是定义了全局对象的一个属性. 当使用var声明一个变量时,创建的这个属性是不可配置的,也就是说这个变量无法通过delete运算符来删除.可能你已经注意到 ...