Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Cant parse array data from db

Hi

How do I extract only the value of a particular object of array from data retrived from a db.

Hi I have similar issue but I am unable to parse the LSV. I just get object object returned after parsing the LSV

The code to retrieve the data from the db.
var dbdata = (JSON.stringify(data));

The result of the above code
{ "resource": [ { "userID":1, "classID":1 }, { "userID":2, "classID":2 } ] }

I want to iterate through this structure and only retrieve the value of the userID's only.

Similar to this suggestion ( https://getsatisfaction.com/apperyio/...)
but it does not actually work when I implement it.

Please can you assist

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Cant parse array data from db

Happy Monday Deon,

How about not stringifying the data.

I assume this is in a success method. In the success method call a function that passes the data. Objective / reason - the function can be debugged in Chrome by stepping through and setting a breakpoint. Not so much in the success method since it's virtually generated by Appery each time - no way to set a breakpoint.

So;

fProcessMyData ( data ) ;

In a separate Javascript asset:

function fProcessMydata ( oDBData) {

var nLength = oDBData.resource.length ;
for ( var nCounter = 0; nCounter < nLength; nCounter++) {
sUserID = oDBData.resource[nCounter].userID ;
// do something with sUserID
//

}

}

Let me know - maybe I missed something here....also - didn't compile in my test - syntax errors possible :-(

Best,

Bruce

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Cant parse array data from db

Hi Bruce

Thank you so much. That worked absolutely perfectly!!!! Much appreciated!

Kind Regards
Deon

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Cant parse array data from db

anytime you need a hand! Glad I could help...

I'm moving away from my day job soon - and headed into making this a full time gig.... so I'll be here a lot more....!

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Cant parse array data from db

That sounds great! I wish you the best. It seems work is starting to pickup my side again. As discussed previously, I would like to outsource any overflow if you are keen?

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Cant parse array data from db

Hi Deon, I'm keen with that and even have a small staff now ... so that would be great !

Return to “Issues”