Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1100189
  • 博文数量: 165
  • 博客积分: 5957
  • 博客等级: 大校
  • 技术积分: 2015
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-24 15:04
文章分类

全部博文(165)

文章存档

2014年(10)

2013年(14)

2012年(9)

2011年(22)

2010年(17)

2009年(17)

2008年(26)

2007年(34)

2006年(16)

我的朋友

分类: Python/Ruby

2011-09-08 17:07:01

json处理,
安装过程:
yum install -y php-pear
pear install pecl/json
cd /etc/php.d
echo "extension=json.so" > json.ini
service httpd restart

After that phpinfo() would output
json support     enabled
json version     1.2.1


json_decode示例:
  1. $app_name = $row->app_name;
  2. $member = exec("/usr/bin/curl \"3124a9448a8\" 2>/dev/null");
  3. $obj = json_decode($member);
  4. $nodelist = split(" ",$obj->data[0]);
  5. print_r($nodelist);

以上是php处理过程


shell处理过程如下:


#echo '{"timestamp":1358496981,"status":200,"request":{"mbean":"com.xxx.yyyy.task:type=ArmorySyncController","type":"read"},"value":{"SyncOpend":true,"AllSyncRecordInfo":333}}' | sed -e 's/[{}"\\]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'
timestamp:1358496981
status:200
request:mbean:com.xxx.yyyy.task:type=ArmorySyncController
type:read
value:SyncOpend:true
AllSyncRecordInfo:333


perl和python处理过程忽略

阅读(945) | 评论(0) | 转发(0) |
0

上一篇:让失去变得有价值

下一篇:不是笑话

给主人留下些什么吧!~~