在JAVA中将JSON数据格式写入数据库

时间:2012-10-16 04:29:54

标签: java jquery json

我正在尝试将JSON数据写入数据库。如何将每列发送到数据库中的相应列。我试图把数据放在

var data = JSON.parse(data)

这不起作用。可变数据仅显示以下格式的信息:

[object Object],[object Object],[object Object],[object Object],[object Object]

我的实际数据格式如下。在编写下面的代码后,我得到以下数据。如何在数据库中保存这些数据?

//生成以下输出的代码。

   $(document).ready(function () {
 $("#check").click(function(){

 var rows = $('#jqxgrid').jqxGrid('getrows');

 var rowData = JSON.stringify(rows);

$.post("GridValues.jsp", {"rowValues": rowData });

 });
    }); 

//如果打印rowData,则输出

[{"empId":"1","fname":"Henry","lname":"Rey","empcat":"Staff","dept":"IT","jTitle":"Software Engg","rAccess":"New Hire","lManager":"Admin","sDate":"2012-10-11","eDate":"2012-10-11","uid":0},{"empId":"2","fname":"Nick","lname":"Murry","empcat":"Staff","dept":"IT","jTitle":"Administrator","rAccess":"New Hire","lManager":"Admin","sDate":"2012-10-11","eDate":"2012-10-11","uid":1},{"empId":"3","fname":"John","lname":"Danilo","empcat":"Staff","dept":"IT","jTitle":"Administrator","rAccess":"New Hire","lManager":"Admin","sDate":"2012-10-11","eDate":"2012-10-11","uid":2},{"empId":"4","fname":"Joene","lname":"Anson","empcat":"Staff","dept":"IT","jTitle":"Software Engg","rAccess":"New Hire","lManager":"Admin","sDate":"2012-10-11","eDate":"2012-10-11","uid":3}]

1 个答案:

答案 0 :(得分:0)

我不能说我完全理解你的问题,这是一个有用的答案,可以帮助你。您可能还想查看Jackson JSON