Retrieving the property name as a string jSon jQuery -


    var days = new array("sun", "mon", "tue", "wed", "thu", "fri", "sat");      $.each(data, function (i, object) {             $.each(object, function (property, value) {             var propertystring = getpropertyasstring(property);             if ($.inarray(propertystring, days) != -1)             {                 //             }             count++;         });     }); 

above code stub i'm using retrieve data json using jquery. want "property name" (i've marked using getpropertyasstring() inside nested $.each() string want check if "property name" exists in days array or not.

to more specific, below json:

[{     "stid": 0,     "vrno": 0,     "vrnoa": 0,     "vrdate": "\/date(-62135596800000)\/",     "party_id": null,     "bilty_no": null,     "bilty_date": "\/date(-62135596800000)\/",     "received_by": null,     "transporter_id": null,     "remarks": null,     "year_srno": 0,     "etype": null,     "namount": 0,     "uid": 0,     "order_vrno": 0,     "freight": 0,     "party_id_co": null,     "salebillno": 0,     "discp": 0,     "discount": 0,     "currency_id": 0,     "expense": 0,     "company_id": 0,     "vehicle_id": null,     "party_name": null,     "iseditted": false,     "isdeleted": false,     "isnew": false,     "mon": "0",     "tue": "0",     "wed": "0",     "thu": "500",     "fri": "0",     "sat": "0",     "sun": "0" }] 

what i'm trying values of week days @ end i.e. mon, tue, wed, thu, fri, sat, sun

i've been trying , trying , can't find way it. kindly please suggest me if there's way around it.

the property variable in example string, don't need convert it.

the actual problem weekday names in object capitalized ("mon", "tue") days array has them in lower case ("mon", "tue"). if days can edit, change match object keys, or use .tolowercase() key you're comparing them to.

if ($.inarray(property.tolowercase(), days) != -1) 

demo: http://jsfiddle.net/phdpp/


Comments

Popular posts from this blog

php - Webix Data Loading from Laravel Link -

libGdx unable to find files in android application data directory -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -