怎么把变量所携带内容赋值到json中

怎么把变量所携带内容赋值到json中,第1张

Store({
2 proxy: new ExtdataScriptTagProxy({
3 url: 'yoururljson'
4 }),
5 reader: new ExtdataJsonReader({
6 root: 'Fields',
7 totalProperty: 'totalCount',
8 id: 'id'
9 }, [
10 ,
11
12 ])
13 });
14 var combobox = new ExtformComboBox({
15 id:'combobox',
16 x:0,
17 y:20,
18 store: da,
19 displayField:'field',
20 typeAhead: false,
21 loadingText: '正在加载字段',
22 forceSelection: false,
23 triggerAction: 'all',
24 hideTrigger:false,
25 minChars:1,
26 anchor: '100%',
27 pageSize:10
28 });
json输出
注意stcCallback1007要用程序输出请求过来的参数callback的值
stcCallback1007(,,,,,,,,]});stcCallback1007(,,,,,,,,]});stcCallback1007(,,,,,,,,]});
不好意思,看错了,以下是grid的
// create the Data Store
var singleTablestore = new ExtdataJsonStore({
root: 'topics',
totalProperty: 'totalCount',
idProperty: 'tableid',
remoteSort: true,
fields: [
,'name','description','importdate'
],
// load using script tags for cross domain, if the data in on the same domain as
proxy: new ExtdataScriptTagProxy({
url: 'abcjson'
})
});
singleTablestoresetDefaultSort('date', 'desc');
var singleTable = new ExtgridEditorGridPanel({
id:'singleTable-panel',
layout:'anchor',
anchor:['100%','100%'],
title:'单表数据处理',
store: singleTablestore,
//trackMouseOver:false,
//disableSelection:true,
loadMask: true,
autoScroll:true,
// grid columns
columns:[{
id: 'name',
header: "数据表名称",
dataIndex: 'name',
width: 200,
sortable: true,
renderer:renderTips
},{
id: 'description', // id assigned so we can apply custom css (eg x-grid-col-topic b )
header: "数据表描述",
dataIndex: 'description',
renderer:renderTips2,
editor:new ExtformTextField(),
width: 270,
// renderer: renderTopic,
sortable: true
},{
header: "导入日期",
dataIndex: 'importdate',
width: 150,
sortable: true
},{
id: 'tableid',
header: " *** 作",
dataIndex: 'tableid',
width: 450,
resizable: false,
//editor:new ExtButton()
renderer: renderLast
//items:[new ExtButton()]
}],
// customize view config
viewConfig: {
//forceFit:true,
enableRowBody:true,
//showPreview:true
},
// paging bar on the bottom
bbar: new ExtPagingToolbar({
pageSize: 20,
store: singleTablestore,
displayInfo: true,
displayMsg: '当前显示 - 条,共 条',
beforePageText:'第',
afterPageText:'页,共页',
emptyMsg: "没有相应内容",
items:[
'-', {
pressed: true,
enableToggle:true,
text: 'Show Preview',
cls: 'x-btn-text-icon details',
toggleHandler: function(btn, pressed){

}
}]
})
});
singleTableon('afteredit', afterEdit, this );
singleTableon('show', function()});}, this );
function afterEdit(e) {

}
abcjson
stcCallback1009(,]});
另外,虚机团上产品团购,超级便宜

直接在当前jsp文件跳转路径到jsp,如果用get方式直接将参数设置到路径后面,如果用post方式,可以创建一个表单form,设置为post方式,将参数设置到表单中提交即可,在第二个jsp中使用${param参数}来获取参数即可

我们知道,JSON是一种轻量级的数据交互的格式,大部分NO SQL数据库的存储都用JSON。MySQL从57开始支持JSON格式的数据存储,并且新增了很多JSON相关函数。MySQL 80 又带来了一个新的把JSON转换为TABLE的函数JSON_TABLE,实现了JSON到表的转换。

举例一

我们看下简单的例子:

简单定义一个两级JSON 对象

mysql> set @ytt='{"name":[{"a":"ytt","b":"action"},  {"a":"dble","b":"shard"},{"a":"mysql","b":"oracle"}]}';Query OK, 0 rows affected (000 sec)

第一级:

mysql> select json_keys(@ytt);+-----------------+| json_keys(@ytt) |+-----------------+| ["name"]        |+-----------------+1 row in set (000 sec)

第二级:

mysql> select json_keys(@ytt,'$name[0]');+-----------------------------+| json_keys(@ytt,'$name[0]') |+-----------------------------+| ["a", "b"]                  |+-----------------------------+1 row in set (000 sec)

我们使用MySQL 80 的JSON_TABLE 来转换 @ytt。

mysql> select from json_table(@ytt,'$name[]' columns (f1 varchar(10) path '$a', f2 varchar(10) path '$b')) as tt;

+-------+--------+

| f1    | f2     |

+-------+--------+

| ytt   | action |

| dble  | shard  |

| mysql | oracle |

+-------+--------+

3 rows in set (000 sec)

举例二

再来一个复杂点的例子,用的是EXPLAIN 的JSON结果集。

JSON 串 @json_str1。

set @json_str1 = ' {  "query_block": {    "select_id": 1,    "cost_info": {      "query_cost": "100"    },    "table": {      "table_name": "bigtable",      "access_type": "const",      "possible_keys": [        "id"      ],      "key": "id",      "used_key_parts": [        "id"      ],      "key_length": "8",      "ref": [        "const"      ],      "rows_examined_per_scan": 1,      "rows_produced_per_join": 1,      "filtered": "10000",      "cost_info": {        "read_cost": "000",        "eval_cost": "020",        "prefix_cost": "000",        "data_read_per_join": "176"      },      "used_columns": [        "id",        "log_time",        "str1",        "str2"      ]    }  }}';


第一级:

mysql> select json_keys(@json_str1) as 'first_object';+-----------------+| first_object    |+-----------------+| ["query_block"] |+-----------------+1 row in set (000 sec)


第二级:

mysql> select json_keys(@json_str1,'$query_block') as 'second_object';+-------------------------------------+| second_object                       |+-------------------------------------+| ["table", "cost_info", "select_id"] |+-------------------------------------+1 row in set (000 sec)


第三级:

mysql>  select json_keys(@json_str1,'$query_blocktable') as 'third_object'\G 1 row third_object: ["key","ref","filtered","cost_info","key_length","table_name","access_type","used_columns","possible_keys","used_key_parts","rows_examined_per_scan","rows_produced_per_join"]1 row in set (001 sec)


第四级:

mysql> select json_extract(@json_str1,'$query_blocktablecost_info') as 'forth_object'\G 1 row forth_object: {"eval_cost":"020","read_cost":"000","prefix_cost":"000","data_read_per_join":"176"}1 row in set (000 sec)


那我们把这个JSON 串转换为表。

SELECT FROM JSON_TABLE(@json_str1,

"$query_block"

COLUMNS(

rowid FOR ORDINALITY,

NESTED PATH '$table'

COLUMNS (

a1_1 varchar(100) PATH '$key',

a1_2 varchar(100) PATH '$ref[0]',

a1_3 varchar(100) PATH '$filtered',

nested path '$cost_info'

columns (

a2_1 varchar(100) PATH '$eval_cost' ,

a2_2 varchar(100) PATH '$read_cost',

a2_3 varchar(100) PATH '$prefix_cost',

a2_4 varchar(100) PATH '$data_read_per_join'

),

a3 varchar(100) PATH '$key_length',

a4 varchar(100) PATH '$table_name',

a5 varchar(100) PATH '$access_type',

a6 varchar(100) PATH '$used_key_parts[0]',

a7 varchar(100) PATH '$rows_examined_per_scan',

a8 varchar(100) PATH '$rows_produced_per_join',

a9 varchar(100) PATH '$key'

),

NESTED PATH '$cost_info'

columns (

b1_1 varchar(100) path '$query_cost'

),

c INT path "$select_id"

)

) AS tt;

+-------+------+-------+--------+------+------+------+------+------+----------+-------+------+------+------+------+------+------+

| rowid | a1_1 | a1_2  | a1_3   | a2_1 | a2_2 | a2_3 | a2_4 | a3   | a4       | a5    | a6   | a7   | a8   | a9   | b1_1 | c    |

+-------+------+-------+--------+------+------+------+------+------+----------+-------+------+------+------+------+------+------+

|     1 | id   | const | 10000 | 020 | 000 | 000 | 176  | 8    | bigtable | const | id   | 1    | 1    | id   | NULL |    1 |

|     1 | NULL | NULL  | NULL   | NULL | NULL | NULL | NULL | NULL | NULL     | NULL  | NULL | NULL | NULL | NULL | 100 |    1 |

+-------+------+-------+--------+------+------+------+------+------+----------+-------+------+------+------+------+------+------+

2 rows in set (000 sec)

当然,JSON_table 函数还有其他的用法,我这里不一一列举了,详细的参考手册。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/13321528.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-14
下一篇 2023-07-14

发表评论

登录后才能评论

评论列表(0条)

保存