Page 1 of 1

Cant parse array data from db

Posted: Mon Feb 06, 2017 6:17 pm
by Deon

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


Cant parse array data from db

Posted: Mon Feb 06, 2017 6:29 pm
by Bruce Stuart

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


Cant parse array data from db

Posted: Tue Feb 07, 2017 1:11 am
by Deon

Hi Bruce

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

Kind Regards
Deon


Cant parse array data from db

Posted: Tue Feb 07, 2017 1:14 am
by Bruce Stuart

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....!


Cant parse array data from db

Posted: Tue Feb 07, 2017 9:11 am
by Deon

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?


Cant parse array data from db

Posted: Tue Feb 07, 2017 12:21 pm
by Bruce Stuart

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