请教:json串中读取属性对应值问题

paging.html代码:
[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Paging Grid Example</title>

<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />

<!-- GC -->
<!-- LIBS -->
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all-debug.js"></script>
<!-- ENDLIBS -->

<script type="text/javascript" src="../../ext-all.js"></script>

<script type="text/javascript" src="paging.js"></script>
<link rel="stylesheet" type="text/css" href="grid-examples.css" />

<!-- Common Styles for the examples -->
<link rel="stylesheet" type="text/css" href="../examples.css" />
</head>
<body>
<script type="text/javascript" src="../examples.js"></script><!-- EXAMPLES -->
<h1>Paging Grid Example</h1>
<p>This example shows how to create a grid with paging. This grid uses a ScriptTagProxy to fetch cross-domain
remote data (from the Ext forums).</p>
<p>Note that the jsis not minified so it is readable. See <a href="paging.js">paging.js</a>.</p>
<!-- <a href="#" οnclick="Ext.log('Hello from the Ext console.');return false;"><img src="inspector.gif" width="600" height="337" style="margin:15px;"/></a>
-->
<div id="topic-grid"></div>

</body>
</html>
[/code]

paging.js代码:
[code]
Ext.onReady(function(){

// create the Data Store
var ds = new Ext.data.Store({
// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
proxy: new Ext.data.HttpProxy({
url: 'a.jsp'//'http://extjs.com/forum/topics-browse-remote.php'
}),

// create reader that reads the Topic records
reader: new Ext.data.JsonReader({
root: 'topics',
totalProperty: 'totalCount',
id: 'threadid'
}, [
'title', 'forumtitle', 'forumid', 'author',
{name: 'replycount', type: 'int'},
{name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
'lastposter', 'excerpt'
]),

// turn on remote sorting
remoteSort: true
});
ds.setDefaultSort('lastpost', 'desc');

// pluggable renders
function renderTopic(value, p, record){
return String.format(
'<b><a href="http://extjs.com/forum/showthread.php?t={2}" target="_blank">{0}</a></b><a href="http://extjs.com/forum/forumdisplay.php?f={3}" target="_blank">{1} Forum</a>',
value, record.data.forumtitle, record.id, record.data.forumid);
}
function renderLast(value, p, r){
return String.format('{0}
by {1}', value.dateFormat('M j, Y, g:i a'), r.data['lastposter']);
}

// the column model has information about grid columns
// dataIndex maps the column to the specific data field in
// the data store
var cm = new Ext.grid.ColumnModel([{
id: 'topic', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
header: "Topic",
dataIndex: 'title',
width: 420,
renderer: renderTopic
},{
header: "Author",
dataIndex: 'author',
width: 100,
hidden: true
},{
header: "Replies",
dataIndex: 'replycount',
width: 70,
align: 'right'
},{
id: 'last',
header: "Last Post",
dataIndex: 'lastpost',
width: 150,
renderer: renderLast
}]);

// by default columns are sortable
cm.defaultSortable = true;

var grid = new Ext.grid.GridPanel({
el:'topic-grid',
width:700,
height:500,
title:'ExtJS.com - Browse Forums',
store: ds,
cm: cm,
trackMouseOver:false,
sm: new Ext.grid.RowSelectionModel({selectRow:Ext.emptyFn}),
loadMask: true,
viewConfig: {
forceFit:true,
enableRowBody:true,
showPreview:true,
getRowClass : function(record, rowIndex, p, ds){
if(this.showPreview){
p.body = '<p>'+record.data.excerpt+'</p>';
return 'x-grid3-row-expanded';
}
return 'x-grid3-row-collapsed';
}
},
bbar: new Ext.PagingToolbar({
pageSize: 25,
store: ds,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display",
items:[
'-', {
pressed: true,
enableToggle:true,
text: 'Show Preview',
cls: 'x-btn-text-icon details',
toggleHandler: toggleDetails
}]
})
});

// render it
grid.render();

// trigger the data store load
ds.load({params:{start:0, limit:25, forumId: 4}});

function toggleDetails(btn, pressed){
var view = grid.getView();
view.showPreview = pressed;
view.refresh();
}
});
[/code]

a.jsp代码:
[code]
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="org.json.simple.*"%>
<%
JSONObject obj = new JSONObject();
JSONArray array = new JSONArray();
JSONObject sub = new JSONObject();
sub.put("threadid", new Integer(12313));
sub.put("forumid", new Integer(32132));
sub.put("forumtitle", "help");
sub.put("title", "EditorGrid saving data in FF, but not IE (no errors, hard to debug)");
sub.put("author", "stevefink");
sub.put("lastposter", "stevefink");
sub.put("lastpost", new Integer(1192160261));
sub.put("excerpt", "Hi all");
sub.put("replycount", new Integer(0));
array.add(sub);
JSONObject sub2 = new JSONObject();
sub2.put("threadid", new Integer(12314));
sub2.put("forumid", new Integer(32132));
sub2.put("forumtitle", "help");
sub2.put("title", "EditorGrid saving data in FF, but not IE (no errors, hard to debug)");
sub2.put("author", "stevefink");
sub2.put("lastposter", "stevefink");
sub2.put("lastpost", new Integer(1192160261));
sub2.put("excerpt", "Hi all");
sub2.put("replycount", new Integer(0));
array.add(sub2);
obj.put("topics", array);
obj.put("status", new Integer(1));
obj.put("totalCount", new Integer(111));
out.print(obj);
%>
[/code]

a.jsp返回值:
[code]
{"totalCount":111,"status":1,"topics":[{"forumid":32132,"title":"EditorGrid saving data in FF, but not IE (no errors, hard to debug)","replycount":0,"lastposter":"stevefink","excerpt":"Hi all","forumtitle":"help","threadid":12313,"lastpost":1192160261,"author":"stevefink"},{"forumid":32132,"title":"EditorGrid saving data in FF, but not IE (no errors, hard to debug)","replycount":0,"lastposter":"stevefink","excerpt":"Hi all","forumtitle":"help","threadid":12314,"lastpost":1192160261,"author":"stevefink"}]}
[/code]

问题:
我想根据属性"status"的对应值来判断是否显示后面的数据,请问如何取出"status"的对应值?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值