0

I'm working on a calendar roster system for work. Unfortunately most solutions/plugins aren't ideal for what I want.

Anywho, what I was wondering is if it possible to select a value from an array output in JSON format, based on multiple criteria. I am using jQuery

to put it fairly generically (haven't started coding it yet):

<for each cell>
--<find ['number_of_slots'] in JSONarray where ['AppointmentDate'] = "02/02/12" && ['salespoint'] = 1 && ['AppointmentTime] = '10AM'>
--<if no results>
-----<fill cell with 'x'>
--<else>
-----<fill cell with ['number_of_slots']
--<end if>

Or am I better off making an MySQL query for each cell? Just seems to be quite a number of transactions, that's all.

As always, any help and advice is greatly appreciated!

Cheers!

Poika
  • 16
  • 3
  • Is manipulating the data as javascript object than parsing it to jSon acceptable? – kidwon Jan 08 '12 at 01:12
  • I'll be honest, I'm not sure how I'd accomplish that. The JSON is provided by PHP from a MySQL database. – Poika Jan 08 '12 at 01:25

1 Answers1

0

If manipulating the data as javascript object than parsing it back to jSon is acceptable:

Parse it to js object: http://api.jquery.com/jQuery.parseJSON/

Parse it back to jSon to String: http://api.jquery.com/jQuery.param/

Parse to jSon issue discussed Convert Object to JSON string

Not the answer to your question but a solution with jQuery, though

Community
  • 1
  • 1
kidwon
  • 4,448
  • 5
  • 28
  • 45
  • Well if I'm able to replicate a MySQL SELECT statment on that object, then, sure. Do you know if this would be the case? – Poika Jan 08 '12 at 01:34
  • Well, you should be able to. Since the jsToJson Parser works in a certain way you can always manipulate the js input in a manner that you reach the desired output. – kidwon Jan 08 '12 at 01:45