Using aspJSON how to I output my recordset as an array
up vote
0
down vote
favorite
At the moment I am doing the following where rs is my recordset
Dim JSON: Set JSON = New JSONobject
Call JSON.LoadRecordset(rs)
Call Response.Clear()
Response.ContentType = "application/json"
Call JSON.Write()
This brings me back data such as this:
{
"data": [
{
"id": "1",
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$320,800",
"start_date": "2011/04/25",
"office": "Edinburgh",
"extn": "5421"
},
{
"id": "2",
"name": "Garrett Winters",
"position": "Accountant",
"salary": "$170,750",
"start_date": "2011/07/25",
"office": "Tokyo",
"extn": "8422"
},
However what if I want it as an array? If I follow the documentation, it just strips the data but how do I get my data to look like the below
{
"data": [
[
"Tiger Nixon",
"System Architect",
"Edinburgh",
"5421",
"2011/04/25",
"$320,800"
],
[
"Garrett Winters",
"Accountant",
"Tokyo",
"8422",
"2011/07/25",
"$170,750"
],
datatables asp-classic
add a comment |
up vote
0
down vote
favorite
At the moment I am doing the following where rs is my recordset
Dim JSON: Set JSON = New JSONobject
Call JSON.LoadRecordset(rs)
Call Response.Clear()
Response.ContentType = "application/json"
Call JSON.Write()
This brings me back data such as this:
{
"data": [
{
"id": "1",
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$320,800",
"start_date": "2011/04/25",
"office": "Edinburgh",
"extn": "5421"
},
{
"id": "2",
"name": "Garrett Winters",
"position": "Accountant",
"salary": "$170,750",
"start_date": "2011/07/25",
"office": "Tokyo",
"extn": "8422"
},
However what if I want it as an array? If I follow the documentation, it just strips the data but how do I get my data to look like the below
{
"data": [
[
"Tiger Nixon",
"System Architect",
"Edinburgh",
"5421",
"2011/04/25",
"$320,800"
],
[
"Garrett Winters",
"Accountant",
"Tokyo",
"8422",
"2011/07/25",
"$170,750"
],
datatables asp-classic
The required json is an array of arrays of only the field values of some of your recordset fields. You could 1)change: the sql query to get only the required fields in required order, 2)In a loop, Add field values to a temp array and keep adding the temp array to a main array. 3) add the main array to a JSONobject with the keyname as "data" and useJSONobject.writeto output. OR, you could just loop through the recordset and output the the values in the required format using a bunch ofResponse.writes. Give it a try, and get back if you have problems.
– SearchAndResQ
Nov 13 at 6:43
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
At the moment I am doing the following where rs is my recordset
Dim JSON: Set JSON = New JSONobject
Call JSON.LoadRecordset(rs)
Call Response.Clear()
Response.ContentType = "application/json"
Call JSON.Write()
This brings me back data such as this:
{
"data": [
{
"id": "1",
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$320,800",
"start_date": "2011/04/25",
"office": "Edinburgh",
"extn": "5421"
},
{
"id": "2",
"name": "Garrett Winters",
"position": "Accountant",
"salary": "$170,750",
"start_date": "2011/07/25",
"office": "Tokyo",
"extn": "8422"
},
However what if I want it as an array? If I follow the documentation, it just strips the data but how do I get my data to look like the below
{
"data": [
[
"Tiger Nixon",
"System Architect",
"Edinburgh",
"5421",
"2011/04/25",
"$320,800"
],
[
"Garrett Winters",
"Accountant",
"Tokyo",
"8422",
"2011/07/25",
"$170,750"
],
datatables asp-classic
At the moment I am doing the following where rs is my recordset
Dim JSON: Set JSON = New JSONobject
Call JSON.LoadRecordset(rs)
Call Response.Clear()
Response.ContentType = "application/json"
Call JSON.Write()
This brings me back data such as this:
{
"data": [
{
"id": "1",
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$320,800",
"start_date": "2011/04/25",
"office": "Edinburgh",
"extn": "5421"
},
{
"id": "2",
"name": "Garrett Winters",
"position": "Accountant",
"salary": "$170,750",
"start_date": "2011/07/25",
"office": "Tokyo",
"extn": "8422"
},
However what if I want it as an array? If I follow the documentation, it just strips the data but how do I get my data to look like the below
{
"data": [
[
"Tiger Nixon",
"System Architect",
"Edinburgh",
"5421",
"2011/04/25",
"$320,800"
],
[
"Garrett Winters",
"Accountant",
"Tokyo",
"8422",
"2011/07/25",
"$170,750"
],
datatables asp-classic
datatables asp-classic
asked Nov 10 at 21:14
Matt Walker
1
1
The required json is an array of arrays of only the field values of some of your recordset fields. You could 1)change: the sql query to get only the required fields in required order, 2)In a loop, Add field values to a temp array and keep adding the temp array to a main array. 3) add the main array to a JSONobject with the keyname as "data" and useJSONobject.writeto output. OR, you could just loop through the recordset and output the the values in the required format using a bunch ofResponse.writes. Give it a try, and get back if you have problems.
– SearchAndResQ
Nov 13 at 6:43
add a comment |
The required json is an array of arrays of only the field values of some of your recordset fields. You could 1)change: the sql query to get only the required fields in required order, 2)In a loop, Add field values to a temp array and keep adding the temp array to a main array. 3) add the main array to a JSONobject with the keyname as "data" and useJSONobject.writeto output. OR, you could just loop through the recordset and output the the values in the required format using a bunch ofResponse.writes. Give it a try, and get back if you have problems.
– SearchAndResQ
Nov 13 at 6:43
The required json is an array of arrays of only the field values of some of your recordset fields. You could 1)change: the sql query to get only the required fields in required order, 2)In a loop, Add field values to a temp array and keep adding the temp array to a main array. 3) add the main array to a JSONobject with the keyname as "data" and use
JSONobject.write to output. OR, you could just loop through the recordset and output the the values in the required format using a bunch of Response.write s. Give it a try, and get back if you have problems.– SearchAndResQ
Nov 13 at 6:43
The required json is an array of arrays of only the field values of some of your recordset fields. You could 1)change: the sql query to get only the required fields in required order, 2)In a loop, Add field values to a temp array and keep adding the temp array to a main array. 3) add the main array to a JSONobject with the keyname as "data" and use
JSONobject.write to output. OR, you could just loop through the recordset and output the the values in the required format using a bunch of Response.write s. Give it a try, and get back if you have problems.– SearchAndResQ
Nov 13 at 6:43
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243469%2fusing-aspjson-how-to-i-output-my-recordset-as-an-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The required json is an array of arrays of only the field values of some of your recordset fields. You could 1)change: the sql query to get only the required fields in required order, 2)In a loop, Add field values to a temp array and keep adding the temp array to a main array. 3) add the main array to a JSONobject with the keyname as "data" and use
JSONobject.writeto output. OR, you could just loop through the recordset and output the the values in the required format using a bunch ofResponse.writes. Give it a try, and get back if you have problems.– SearchAndResQ
Nov 13 at 6:43