[Proto-Scripty] Re: Nested JSON problem

2008-12-19 Thread George

No it just means that you can only nest your data to a depth of 512 on
the php server side.  Imagine navigating that!

On Dec 18, 7:26 pm, jason maina jason.ma...@gmail.com wrote:
 Is it to mean that it cant support a large 'recordset' ?

 On 12/18/08, Richard Quadling rquadl...@googlemail.com wrote:



  2008/12/18 jason maina jason.ma...@gmail.com:
  Hi George,

  Thanks for the input.
  Well, the data is converted to json by php from a nested array after
  extracting the data from a database thus the reason why there's  flowerset
  and flowers.

  Im finally through with it, it looks kinda complicated in the nesting
  element but it somehow while retreiving the data it was easy remebering
  the
  various layers.

  On the same breath will be looking into streamlining it and making it thin
  as you have outlined.

  Thanks
  Regards
  Jason

  On Thu, Dec 18, 2008 at 4:42 PM, George george.bea...@googlemail.com
  wrote:

  Hi Jason,

  Forgive me if I've misunderstood the question, but hopefully this
  might help.

  As far as I know, you can infinitely nest your JSON data if that's
  what you want to do.  I've noticed some fundamental problems with your
  JSON you pasted in your post which may just be typos, but need to be
  cleared up before your code will work.  Firstly the items in your
  'flowerset' are not enclosed in square brackets.  Secondly your names
  (eg groupCode) do not need to be enclosed in quotations although this
  won't break things.  Thirdly, in my opinion, you could break this down
  and request a much smaller and less complex dataset from the server
  (maybe just the group names first, then depending on what the user
  clicked on get the flower names and so on)  Thus putting less load on
  the server and reducing bandwidth.  Also, I'd say to have everything
  nested under the name rsJson just adds another unnecessary dimension
  of complication.

  Think of JSON as just a long bunch of name value pairs [{name:value}]
  separated by commas where a value can be a number, string or another
  array.  If your value is another array, then it must be enclosed in
  square brackets.  As such, there should never be a curly bracket
  immediately after a colon ( [{name:{name:value, name:value},
  name:value}] ) is wrong.  [{name:[{name:value, name:value}],
  name:value}] is correct.

  I've cleaned up a little bit of your data just to demonstrate the
  correct syntax:

  {rsJson:
   [
     {groupCode:1,groupName:Roses,flowerSet:[
       {flowers: [
         {flowerCode:15,flowerName:Roses}
         ]}
       ]},
     {groupCode:2,groupName:Carnations,flowerSet:[
       {flowers:[
         {flowerCode:16,flowerName:Spray Carnations},
         {flowerCode:17,flowerName:Standard Carnations}
         ]}
       ]}
   ]}

  To get to your data do something like this:

  myDataSetVar[0].rsJson[0].groupCode   (would give you 1)
  myDataSetVar[0].rsJson[1].flowerSet[0].flowers[1].flowerName  (would
  give you Standard Carnations)

  Really hope that helps and I haven't confused things further.

  All the best

  George

  On Dec 18, 9:04 am, jason maina jason.ma...@gmail.com wrote:
   Thanks Ryan guess was kind of tired had failed looking at some of the
   points
   rather was not getting the point. Finally I'm through this is the final
   product:

   {rsJson:[{groupCode:1,groupName:Roses,flowerSet:{flowers:[{flowerCode:15,flowerName:Roses}]}},{groupCode:2,groupName:Carnations,flowerSet:{flowers:[{flowerCode:16,flowerName:Spray
   Carnations},{flowerCode:17,flowerName:Standard

   Carnations}]}},{groupCode:3,groupName:Perennials,flowerSet:{flowers:[{flowerCode:2,flowerName:Aster},{flowerCode:3,flowerName:Alstromeria},{flowerCode:10,flowerName:Gysophila},{flowerCode:12,flowerName:Limonium

   Perezzi}]}},{groupCode:4,groupName:Annuals,flowerSet:{flowers:[{flowerCode:1,flowerName:Ammi

   Majus},{flowerCode:4,flowerName:Bupleurum},{flowerCode:5,flowerName:Carthamus},{flowerCode:6,flowerName:Chinese

   Aster},{flowerCode:7,flowerName:Chrysantemum},{flowerCode:8,flowerName:Delphinium},{flowerCode:13,flowerName:Lisianthus},{flowerCode:14,flowerName:Molucella},{flowerCode:18,flowerName:Statice},{flowerCode:19,flowerName:Stocks}]}},{groupCode:5,groupName:Bulbs,flowerSet:{flowers:[{flowerCode:9,flowerName:Freesia},{flowerCode:11,flowerName:Lilies}]}}]}

   kind regards
   Jason

   On Wed, Dec 17, 2008 at 8:04 PM, jason maina jason.ma...@gmail.com
   wrote:
What im wondering out of the reply is I cant have a nested JSON
object
with
the following layout?

groupID, groupName, groupItems(array of items)

similar example:

http://labs.adobe.com/technologies/spry/samples/data_region/JSONDataS...

Regards,
Jason

On Wed, Dec 17, 2008 at 7:02 PM, Ryan Gahl ryan.g...@gmail.com
wrote:

typo... ...with NO properties

On Wed, Dec 17, 2008 at 10:02 AM, Ryan Gahl ryan.g...@gmail.com
wrote:

Here are your problems... I'll remove the bulk of the data to make

[Proto-Scripty] Re: Nested JSON problem

2008-12-18 Thread George

Hi Jason,

Forgive me if I've misunderstood the question, but hopefully this
might help.

As far as I know, you can infinitely nest your JSON data if that's
what you want to do.  I've noticed some fundamental problems with your
JSON you pasted in your post which may just be typos, but need to be
cleared up before your code will work.  Firstly the items in your
'flowerset' are not enclosed in square brackets.  Secondly your names
(eg groupCode) do not need to be enclosed in quotations although this
won't break things.  Thirdly, in my opinion, you could break this down
and request a much smaller and less complex dataset from the server
(maybe just the group names first, then depending on what the user
clicked on get the flower names and so on)  Thus putting less load on
the server and reducing bandwidth.  Also, I'd say to have everything
nested under the name rsJson just adds another unnecessary dimension
of complication.

Think of JSON as just a long bunch of name value pairs [{name:value}]
separated by commas where a value can be a number, string or another
array.  If your value is another array, then it must be enclosed in
square brackets.  As such, there should never be a curly bracket
immediately after a colon ( [{name:{name:value, name:value},
name:value}] ) is wrong.  [{name:[{name:value, name:value}],
name:value}] is correct.

I've cleaned up a little bit of your data just to demonstrate the
correct syntax:

{rsJson:
  [
{groupCode:1,groupName:Roses,flowerSet:[
  {flowers: [
{flowerCode:15,flowerName:Roses}
]}
  ]},
{groupCode:2,groupName:Carnations,flowerSet:[
  {flowers:[
{flowerCode:16,flowerName:Spray Carnations},
{flowerCode:17,flowerName:Standard Carnations}
]}
  ]}
  ]}

To get to your data do something like this:

myDataSetVar[0].rsJson[0].groupCode   (would give you 1)
myDataSetVar[0].rsJson[1].flowerSet[0].flowers[1].flowerName  (would
give you Standard Carnations)


Really hope that helps and I haven't confused things further.

All the best

George


On Dec 18, 9:04 am, jason maina jason.ma...@gmail.com wrote:
 Thanks Ryan guess was kind of tired had failed looking at some of the points
 rather was not getting the point. Finally I'm through this is the final
 product:

 {rsJson:[{groupCode:1,groupName:Roses,flowerSet:{flowers:[{flowerCode:15,flowerName:Roses}]}},{groupCode:2,groupName:Carnations,flowerSet:{flowers:[{flowerCode:16,flowerName:Spray
 Carnations},{flowerCode:17,flowerName:Standard
 Carnations}]}},{groupCode:3,groupName:Perennials,flowerSet:{flowers:[{flowerCode:2,flowerName:Aster},{flowerCode:3,flowerName:Alstromeria},{flowerCode:10,flowerName:Gysophila},{flowerCode:12,flowerName:Limonium
 Perezzi}]}},{groupCode:4,groupName:Annuals,flowerSet:{flowers:[{flowerCode:1,flowerName:Ammi
 Majus},{flowerCode:4,flowerName:Bupleurum},{flowerCode:5,flowerName:Carthamus},{flowerCode:6,flowerName:Chinese
 Aster},{flowerCode:7,flowerName:Chrysantemum},{flowerCode:8,flowerName:Delphinium},{flowerCode:13,flowerName:Lisianthus},{flowerCode:14,flowerName:Molucella},{flowerCode:18,flowerName:Statice},{flowerCode:19,flowerName:Stocks}]}},{groupCode:5,groupName:Bulbs,flowerSet:{flowers:[{flowerCode:9,flowerName:Freesia},{flowerCode:11,flowerName:Lilies}]}}]}

 kind regards
 Jason

 On Wed, Dec 17, 2008 at 8:04 PM, jason maina jason.ma...@gmail.com wrote:
  What im wondering out of the reply is I cant have a nested JSON object with
  the following layout?

  groupID, groupName, groupItems(array of items)

  similar example:

 http://labs.adobe.com/technologies/spry/samples/data_region/JSONDataS...

  Regards,
  Jason

  On Wed, Dec 17, 2008 at 7:02 PM, Ryan Gahl ryan.g...@gmail.com wrote:

  typo... ...with NO properties

  On Wed, Dec 17, 2008 at 10:02 AM, Ryan Gahl ryan.g...@gmail.com wrote:

  Here are your problems... I'll remove the bulk of the data to make it
  more clear:

  rsJson: {[{...}]}

  what you have is illegal. You're essentially saying you have an anonymous
  object with not properties and filling it with an array (that's probably 
  not
  even totally accurate)... the bottom line is, you can't have a curly brace
  immediately followed by a square brace. And going further you have it all
  just sitting in a property floating in space. The first thing you need to 
  do
  is wrap the property in curlies so you're actually returning an object...

  {rsJson: ...}

  Now, this other issue of putting a square bracket right inside a curly...
  You can either a) remove the outer curlies and just make rsJson be an 
  array,
  or b) add a property name which then becomes the array.

  a)
  {rsJson: [{}, {}, ...]}

  b)
  {rsJson: {myArray: [...]}}

  On Wed, Dec 17, 2008 at 9:53 AM, jason maina jason.ma...@gmail.comwrote:

  Hi all,
  Below is JSON encoded(php) data. After evaluating and sanitizing it im
  not capable of extracting its contents im just not sure what im doing 
  wrong:

  [php output]

  

[Proto-Scripty] Re: Nested JSON problem

2008-12-18 Thread jason maina
Hi George,

Thanks for the input.
Well, the data is converted to json by php from a nested array after
extracting the data from a database thus the reason why there's  flowerset
and flowers.

Im finally through with it, it looks kinda complicated in the nesting
element but it somehow while retreiving the data it was easy remebering the
various layers.

On the same breath will be looking into streamlining it and making it thin
as you have outlined.

Thanks
Regards
Jason

On Thu, Dec 18, 2008 at 4:42 PM, George george.bea...@googlemail.comwrote:


 Hi Jason,

 Forgive me if I've misunderstood the question, but hopefully this
 might help.

 As far as I know, you can infinitely nest your JSON data if that's
 what you want to do.  I've noticed some fundamental problems with your
 JSON you pasted in your post which may just be typos, but need to be
 cleared up before your code will work.  Firstly the items in your
 'flowerset' are not enclosed in square brackets.  Secondly your names
 (eg groupCode) do not need to be enclosed in quotations although this
 won't break things.  Thirdly, in my opinion, you could break this down
 and request a much smaller and less complex dataset from the server
 (maybe just the group names first, then depending on what the user
 clicked on get the flower names and so on)  Thus putting less load on
 the server and reducing bandwidth.  Also, I'd say to have everything
 nested under the name rsJson just adds another unnecessary dimension
 of complication.

 Think of JSON as just a long bunch of name value pairs [{name:value}]
 separated by commas where a value can be a number, string or another
 array.  If your value is another array, then it must be enclosed in
 square brackets.  As such, there should never be a curly bracket
 immediately after a colon ( [{name:{name:value, name:value},
 name:value}] ) is wrong.  [{name:[{name:value, name:value}],
 name:value}] is correct.

 I've cleaned up a little bit of your data just to demonstrate the
 correct syntax:

 {rsJson:
   [
{groupCode:1,groupName:Roses,flowerSet:[
  {flowers: [
{flowerCode:15,flowerName:Roses}
]}
  ]},
{groupCode:2,groupName:Carnations,flowerSet:[
  {flowers:[
{flowerCode:16,flowerName:Spray Carnations},
{flowerCode:17,flowerName:Standard Carnations}
]}
   ]}
  ]}

 To get to your data do something like this:

 myDataSetVar[0].rsJson[0].groupCode   (would give you 1)
 myDataSetVar[0].rsJson[1].flowerSet[0].flowers[1].flowerName  (would
 give you Standard Carnations)


 Really hope that helps and I haven't confused things further.

 All the best

 George


 On Dec 18, 9:04 am, jason maina jason.ma...@gmail.com wrote:
  Thanks Ryan guess was kind of tired had failed looking at some of the
 points
  rather was not getting the point. Finally I'm through this is the final
  product:
 
 
 {rsJson:[{groupCode:1,groupName:Roses,flowerSet:{flowers:[{flowerCode:15,flowerName:Roses}]}},{groupCode:2,groupName:Carnations,flowerSet:{flowers:[{flowerCode:16,flowerName:Spray
  Carnations},{flowerCode:17,flowerName:Standard
 
 Carnations}]}},{groupCode:3,groupName:Perennials,flowerSet:{flowers:[{flowerCode:2,flowerName:Aster},{flowerCode:3,flowerName:Alstromeria},{flowerCode:10,flowerName:Gysophila},{flowerCode:12,flowerName:Limonium
 
 Perezzi}]}},{groupCode:4,groupName:Annuals,flowerSet:{flowers:[{flowerCode:1,flowerName:Ammi
 
 Majus},{flowerCode:4,flowerName:Bupleurum},{flowerCode:5,flowerName:Carthamus},{flowerCode:6,flowerName:Chinese
 
 Aster},{flowerCode:7,flowerName:Chrysantemum},{flowerCode:8,flowerName:Delphinium},{flowerCode:13,flowerName:Lisianthus},{flowerCode:14,flowerName:Molucella},{flowerCode:18,flowerName:Statice},{flowerCode:19,flowerName:Stocks}]}},{groupCode:5,groupName:Bulbs,flowerSet:{flowers:[{flowerCode:9,flowerName:Freesia},{flowerCode:11,flowerName:Lilies}]}}]}
 
  kind regards
  Jason
 
  On Wed, Dec 17, 2008 at 8:04 PM, jason maina jason.ma...@gmail.com
 wrote:
   What im wondering out of the reply is I cant have a nested JSON object
 with
   the following layout?
 
   groupID, groupName, groupItems(array of items)
 
   similar example:
 
  http://labs.adobe.com/technologies/spry/samples/data_region/JSONDataS.
 ..
 
   Regards,
   Jason
 
   On Wed, Dec 17, 2008 at 7:02 PM, Ryan Gahl ryan.g...@gmail.com
 wrote:
 
   typo... ...with NO properties
 
   On Wed, Dec 17, 2008 at 10:02 AM, Ryan Gahl ryan.g...@gmail.com
 wrote:
 
   Here are your problems... I'll remove the bulk of the data to make it
   more clear:
 
   rsJson: {[{...}]}
 
   what you have is illegal. You're essentially saying you have an
 anonymous
   object with not properties and filling it with an array (that's
 probably not
   even totally accurate)... the bottom line is, you can't have a curly
 brace
   immediately followed by a square brace. And going further you have it
 all
   just sitting in a property floating in space. The first thing you
 need to do
   is wrap the 

[Proto-Scripty] Re: Nested JSON problem

2008-12-18 Thread Richard Quadling

2008/12/18 jason maina jason.ma...@gmail.com:
 Hi George,

 Thanks for the input.
 Well, the data is converted to json by php from a nested array after
 extracting the data from a database thus the reason why there's  flowerset
 and flowers.

 Im finally through with it, it looks kinda complicated in the nesting
 element but it somehow while retreiving the data it was easy remebering the
 various layers.

 On the same breath will be looking into streamlining it and making it thin
 as you have outlined.

 Thanks
 Regards
 Jason

 On Thu, Dec 18, 2008 at 4:42 PM, George george.bea...@googlemail.com
 wrote:

 Hi Jason,

 Forgive me if I've misunderstood the question, but hopefully this
 might help.

 As far as I know, you can infinitely nest your JSON data if that's
 what you want to do.  I've noticed some fundamental problems with your
 JSON you pasted in your post which may just be typos, but need to be
 cleared up before your code will work.  Firstly the items in your
 'flowerset' are not enclosed in square brackets.  Secondly your names
 (eg groupCode) do not need to be enclosed in quotations although this
 won't break things.  Thirdly, in my opinion, you could break this down
 and request a much smaller and less complex dataset from the server
 (maybe just the group names first, then depending on what the user
 clicked on get the flower names and so on)  Thus putting less load on
 the server and reducing bandwidth.  Also, I'd say to have everything
 nested under the name rsJson just adds another unnecessary dimension
 of complication.

 Think of JSON as just a long bunch of name value pairs [{name:value}]
 separated by commas where a value can be a number, string or another
 array.  If your value is another array, then it must be enclosed in
 square brackets.  As such, there should never be a curly bracket
 immediately after a colon ( [{name:{name:value, name:value},
 name:value}] ) is wrong.  [{name:[{name:value, name:value}],
 name:value}] is correct.

 I've cleaned up a little bit of your data just to demonstrate the
 correct syntax:

 {rsJson:
  [
{groupCode:1,groupName:Roses,flowerSet:[
  {flowers: [
{flowerCode:15,flowerName:Roses}
]}
  ]},
{groupCode:2,groupName:Carnations,flowerSet:[
  {flowers:[
{flowerCode:16,flowerName:Spray Carnations},
{flowerCode:17,flowerName:Standard Carnations}
]}
  ]}
  ]}

 To get to your data do something like this:

 myDataSetVar[0].rsJson[0].groupCode   (would give you 1)
 myDataSetVar[0].rsJson[1].flowerSet[0].flowers[1].flowerName  (would
 give you Standard Carnations)


 Really hope that helps and I haven't confused things further.

 All the best

 George


 On Dec 18, 9:04 am, jason maina jason.ma...@gmail.com wrote:
  Thanks Ryan guess was kind of tired had failed looking at some of the
  points
  rather was not getting the point. Finally I'm through this is the final
  product:
 
 
  {rsJson:[{groupCode:1,groupName:Roses,flowerSet:{flowers:[{flowerCode:15,flowerName:Roses}]}},{groupCode:2,groupName:Carnations,flowerSet:{flowers:[{flowerCode:16,flowerName:Spray
  Carnations},{flowerCode:17,flowerName:Standard
 
  Carnations}]}},{groupCode:3,groupName:Perennials,flowerSet:{flowers:[{flowerCode:2,flowerName:Aster},{flowerCode:3,flowerName:Alstromeria},{flowerCode:10,flowerName:Gysophila},{flowerCode:12,flowerName:Limonium
 
  Perezzi}]}},{groupCode:4,groupName:Annuals,flowerSet:{flowers:[{flowerCode:1,flowerName:Ammi
 
  Majus},{flowerCode:4,flowerName:Bupleurum},{flowerCode:5,flowerName:Carthamus},{flowerCode:6,flowerName:Chinese
 
  Aster},{flowerCode:7,flowerName:Chrysantemum},{flowerCode:8,flowerName:Delphinium},{flowerCode:13,flowerName:Lisianthus},{flowerCode:14,flowerName:Molucella},{flowerCode:18,flowerName:Statice},{flowerCode:19,flowerName:Stocks}]}},{groupCode:5,groupName:Bulbs,flowerSet:{flowers:[{flowerCode:9,flowerName:Freesia},{flowerCode:11,flowerName:Lilies}]}}]}
 
  kind regards
  Jason
 
  On Wed, Dec 17, 2008 at 8:04 PM, jason maina jason.ma...@gmail.com
  wrote:
   What im wondering out of the reply is I cant have a nested JSON object
   with
   the following layout?
 
   groupID, groupName, groupItems(array of items)
 
   similar example:
 
 
   http://labs.adobe.com/technologies/spry/samples/data_region/JSONDataS...
 
   Regards,
   Jason
 
   On Wed, Dec 17, 2008 at 7:02 PM, Ryan Gahl ryan.g...@gmail.com
   wrote:
 
   typo... ...with NO properties
 
   On Wed, Dec 17, 2008 at 10:02 AM, Ryan Gahl ryan.g...@gmail.com
   wrote:
 
   Here are your problems... I'll remove the bulk of the data to make
   it
   more clear:
 
   rsJson: {[{...}]}
 
   what you have is illegal. You're essentially saying you have an
   anonymous
   object with not properties and filling it with an array (that's
   probably not
   even totally accurate)... the bottom line is, you can't have a curly
   brace
   immediately followed by a square brace. And going further you have
   it all
   just sitting 

[Proto-Scripty] Re: Nested JSON problem

2008-12-18 Thread George

You learn something every day!  Many thanks for that Richard.

On Dec 18, 4:16 pm, Richard Quadling rquadl...@googlemail.com
wrote:
 2008/12/18 jason maina jason.ma...@gmail.com:



  Hi George,

  Thanks for the input.
  Well, the data is converted to json by php from a nested array after
  extracting the data from a database thus the reason why there's  flowerset
  and flowers.

  Im finally through with it, it looks kinda complicated in the nesting
  element but it somehow while retreiving the data it was easy remebering the
  various layers.

  On the same breath will be looking into streamlining it and making it thin
  as you have outlined.

  Thanks
  Regards
  Jason

  On Thu, Dec 18, 2008 at 4:42 PM, George george.bea...@googlemail.com
  wrote:

  Hi Jason,

  Forgive me if I've misunderstood the question, but hopefully this
  might help.

  As far as I know, you can infinitely nest your JSON data if that's
  what you want to do.  I've noticed some fundamental problems with your
  JSON you pasted in your post which may just be typos, but need to be
  cleared up before your code will work.  Firstly the items in your
  'flowerset' are not enclosed in square brackets.  Secondly your names
  (eg groupCode) do not need to be enclosed in quotations although this
  won't break things.  Thirdly, in my opinion, you could break this down
  and request a much smaller and less complex dataset from the server
  (maybe just the group names first, then depending on what the user
  clicked on get the flower names and so on)  Thus putting less load on
  the server and reducing bandwidth.  Also, I'd say to have everything
  nested under the name rsJson just adds another unnecessary dimension
  of complication.

  Think of JSON as just a long bunch of name value pairs [{name:value}]
  separated by commas where a value can be a number, string or another
  array.  If your value is another array, then it must be enclosed in
  square brackets.  As such, there should never be a curly bracket
  immediately after a colon ( [{name:{name:value, name:value},
  name:value}] ) is wrong.  [{name:[{name:value, name:value}],
  name:value}] is correct.

  I've cleaned up a little bit of your data just to demonstrate the
  correct syntax:

  {rsJson:
   [
     {groupCode:1,groupName:Roses,flowerSet:[
       {flowers: [
         {flowerCode:15,flowerName:Roses}
         ]}
       ]},
     {groupCode:2,groupName:Carnations,flowerSet:[
       {flowers:[
         {flowerCode:16,flowerName:Spray Carnations},
         {flowerCode:17,flowerName:Standard Carnations}
         ]}
       ]}
   ]}

  To get to your data do something like this:

  myDataSetVar[0].rsJson[0].groupCode   (would give you 1)
  myDataSetVar[0].rsJson[1].flowerSet[0].flowers[1].flowerName  (would
  give you Standard Carnations)

  Really hope that helps and I haven't confused things further.

  All the best

  George

  On Dec 18, 9:04 am, jason maina jason.ma...@gmail.com wrote:
   Thanks Ryan guess was kind of tired had failed looking at some of the
   points
   rather was not getting the point. Finally I'm through this is the final
   product:

   {rsJson:[{groupCode:1,groupName:Roses,flowerSet:{flowers:[{flowerCode:15,flowerName:Roses}]}},{groupCode:2,groupName:Carnations,flowerSet:{flowers:[{flowerCode:16,flowerName:Spray
   Carnations},{flowerCode:17,flowerName:Standard

   Carnations}]}},{groupCode:3,groupName:Perennials,flowerSet:{flowers:[{flowerCode:2,flowerName:Aster},{flowerCode:3,flowerName:Alstromeria},{flowerCode:10,flowerName:Gysophila},{flowerCode:12,flowerName:Limonium

   Perezzi}]}},{groupCode:4,groupName:Annuals,flowerSet:{flowers:[{flowerCode:1,flowerName:Ammi

   Majus},{flowerCode:4,flowerName:Bupleurum},{flowerCode:5,flowerName:Carthamus},{flowerCode:6,flowerName:Chinese

   Aster},{flowerCode:7,flowerName:Chrysantemum},{flowerCode:8,flowerName:Delphinium},{flowerCode:13,flowerName:Lisianthus},{flowerCode:14,flowerName:Molucella},{flowerCode:18,flowerName:Statice},{flowerCode:19,flowerName:Stocks}]}},{groupCode:5,groupName:Bulbs,flowerSet:{flowers:[{flowerCode:9,flowerName:Freesia},{flowerCode:11,flowerName:Lilies}]}}]}

   kind regards
   Jason

   On Wed, Dec 17, 2008 at 8:04 PM, jason maina jason.ma...@gmail.com
   wrote:
What im wondering out of the reply is I cant have a nested JSON object
with
the following layout?

groupID, groupName, groupItems(array of items)

similar example:

http://labs.adobe.com/technologies/spry/samples/data_region/JSONDataS...

Regards,
Jason

On Wed, Dec 17, 2008 at 7:02 PM, Ryan Gahl ryan.g...@gmail.com
wrote:

typo... ...with NO properties

On Wed, Dec 17, 2008 at 10:02 AM, Ryan Gahl ryan.g...@gmail.com
wrote:

Here are your problems... I'll remove the bulk of the data to make
it
more clear:

rsJson: {[{...}]}

what you have is illegal. You're essentially saying you have an
anonymous
object with not properties and filling it with 

[Proto-Scripty] Re: Nested JSON problem

2008-12-18 Thread jason maina

Is it to mean that it cant support a large 'recordset' ?

On 12/18/08, Richard Quadling rquadl...@googlemail.com wrote:

 2008/12/18 jason maina jason.ma...@gmail.com:
 Hi George,

 Thanks for the input.
 Well, the data is converted to json by php from a nested array after
 extracting the data from a database thus the reason why there's  flowerset
 and flowers.

 Im finally through with it, it looks kinda complicated in the nesting
 element but it somehow while retreiving the data it was easy remebering
 the
 various layers.

 On the same breath will be looking into streamlining it and making it thin
 as you have outlined.

 Thanks
 Regards
 Jason

 On Thu, Dec 18, 2008 at 4:42 PM, George george.bea...@googlemail.com
 wrote:

 Hi Jason,

 Forgive me if I've misunderstood the question, but hopefully this
 might help.

 As far as I know, you can infinitely nest your JSON data if that's
 what you want to do.  I've noticed some fundamental problems with your
 JSON you pasted in your post which may just be typos, but need to be
 cleared up before your code will work.  Firstly the items in your
 'flowerset' are not enclosed in square brackets.  Secondly your names
 (eg groupCode) do not need to be enclosed in quotations although this
 won't break things.  Thirdly, in my opinion, you could break this down
 and request a much smaller and less complex dataset from the server
 (maybe just the group names first, then depending on what the user
 clicked on get the flower names and so on)  Thus putting less load on
 the server and reducing bandwidth.  Also, I'd say to have everything
 nested under the name rsJson just adds another unnecessary dimension
 of complication.

 Think of JSON as just a long bunch of name value pairs [{name:value}]
 separated by commas where a value can be a number, string or another
 array.  If your value is another array, then it must be enclosed in
 square brackets.  As such, there should never be a curly bracket
 immediately after a colon ( [{name:{name:value, name:value},
 name:value}] ) is wrong.  [{name:[{name:value, name:value}],
 name:value}] is correct.

 I've cleaned up a little bit of your data just to demonstrate the
 correct syntax:

 {rsJson:
  [
{groupCode:1,groupName:Roses,flowerSet:[
  {flowers: [
{flowerCode:15,flowerName:Roses}
]}
  ]},
{groupCode:2,groupName:Carnations,flowerSet:[
  {flowers:[
{flowerCode:16,flowerName:Spray Carnations},
{flowerCode:17,flowerName:Standard Carnations}
]}
  ]}
  ]}

 To get to your data do something like this:

 myDataSetVar[0].rsJson[0].groupCode   (would give you 1)
 myDataSetVar[0].rsJson[1].flowerSet[0].flowers[1].flowerName  (would
 give you Standard Carnations)


 Really hope that helps and I haven't confused things further.

 All the best

 George


 On Dec 18, 9:04 am, jason maina jason.ma...@gmail.com wrote:
  Thanks Ryan guess was kind of tired had failed looking at some of the
  points
  rather was not getting the point. Finally I'm through this is the final
  product:
 
 
  {rsJson:[{groupCode:1,groupName:Roses,flowerSet:{flowers:[{flowerCode:15,flowerName:Roses}]}},{groupCode:2,groupName:Carnations,flowerSet:{flowers:[{flowerCode:16,flowerName:Spray
  Carnations},{flowerCode:17,flowerName:Standard
 
  Carnations}]}},{groupCode:3,groupName:Perennials,flowerSet:{flowers:[{flowerCode:2,flowerName:Aster},{flowerCode:3,flowerName:Alstromeria},{flowerCode:10,flowerName:Gysophila},{flowerCode:12,flowerName:Limonium
 
  Perezzi}]}},{groupCode:4,groupName:Annuals,flowerSet:{flowers:[{flowerCode:1,flowerName:Ammi
 
  Majus},{flowerCode:4,flowerName:Bupleurum},{flowerCode:5,flowerName:Carthamus},{flowerCode:6,flowerName:Chinese
 
  Aster},{flowerCode:7,flowerName:Chrysantemum},{flowerCode:8,flowerName:Delphinium},{flowerCode:13,flowerName:Lisianthus},{flowerCode:14,flowerName:Molucella},{flowerCode:18,flowerName:Statice},{flowerCode:19,flowerName:Stocks}]}},{groupCode:5,groupName:Bulbs,flowerSet:{flowers:[{flowerCode:9,flowerName:Freesia},{flowerCode:11,flowerName:Lilies}]}}]}
 
  kind regards
  Jason
 
  On Wed, Dec 17, 2008 at 8:04 PM, jason maina jason.ma...@gmail.com
  wrote:
   What im wondering out of the reply is I cant have a nested JSON
   object
   with
   the following layout?
 
   groupID, groupName, groupItems(array of items)
 
   similar example:
 
 
   http://labs.adobe.com/technologies/spry/samples/data_region/JSONDataS...
 
   Regards,
   Jason
 
   On Wed, Dec 17, 2008 at 7:02 PM, Ryan Gahl ryan.g...@gmail.com
   wrote:
 
   typo... ...with NO properties
 
   On Wed, Dec 17, 2008 at 10:02 AM, Ryan Gahl ryan.g...@gmail.com
   wrote:
 
   Here are your problems... I'll remove the bulk of the data to make
   it
   more clear:
 
   rsJson: {[{...}]}
 
   what you have is illegal. You're essentially saying you have an
   anonymous
   object with not properties and filling it with an array (that's
   probably not
   even totally accurate)... the bottom line is, 

[Proto-Scripty] Re: Nested JSON problem

2008-12-17 Thread jason maina
What im wondering out of the reply is I cant have a nested JSON object with
the following layout?

groupID, groupName, groupItems(array of items)

similar example:
http://labs.adobe.com/technologies/spry/samples/data_region/JSONDataSetSample.html#Example5

Regards,
Jason


On Wed, Dec 17, 2008 at 7:02 PM, Ryan Gahl ryan.g...@gmail.com wrote:

 typo... ...with NO properties



 On Wed, Dec 17, 2008 at 10:02 AM, Ryan Gahl ryan.g...@gmail.com wrote:

 Here are your problems... I'll remove the bulk of the data to make it more
 clear:

 rsJson: {[{...}]}

 what you have is illegal. You're essentially saying you have an anonymous
 object with not properties and filling it with an array (that's probably not
 even totally accurate)... the bottom line is, you can't have a curly brace
 immediately followed by a square brace. And going further you have it all
 just sitting in a property floating in space. The first thing you need to do
 is wrap the property in curlies so you're actually returning an object...

 {rsJson: ...}

 Now, this other issue of putting a square bracket right inside a curly...
 You can either a) remove the outer curlies and just make rsJson be an array,
 or b) add a property name which then becomes the array.

 a)
 {rsJson: [{}, {}, ...]}

 b)
 {rsJson: {myArray: [...]}}




 On Wed, Dec 17, 2008 at 9:53 AM, jason maina jason.ma...@gmail.comwrote:

 Hi all,
 Below is JSON encoded(php) data. After evaluating and sanitizing it im
 not capable of extracting its contents im just not sure what im doing wrong:

 [php output]


 rsJson:{[{groupCode:1,groupName:Roses,flowers:[{flowerCode:15,flowerName:Roses}]},
 {groupCode:2,groupName:Carnations,flowers:[{flowerCode:16,flowerName:Spray
 Carnations
 },{flowerCode:17,flowerName:Standard
 Carnations}]},{groupCode:3,groupName:Perennials

 ,flowers:[{flowerCode:2,flowerName:Aster},{flowerCode:3,flowerName:Alstromeria},{flowerCode
 :10,flowerName:Gysophila},{flowerCode:12,flowerName:Limonium
 Perezzi}]},{groupCode:4
 ,groupName:Annuals,flowers:[{flowerCode:1,flowerName:Ammi
 Majus},{flowerCode:4,flowerName
 :Bupleurum},{flowerCode:5,flowerName:Carthamus},{flowerCode:6,flowerName:Chinese
 Aster

 },{flowerCode:7,flowerName:Chrysantemum},{flowerCode:8,flowerName:Delphinium},{flowerCode

 :13,flowerName:Lisianthus},{flowerCode:14,flowerName:Molucella},{flowerCode:18,flowerName

 :Statice},{flowerCode:19,flowerName:Stocks}]},{groupCode:5,groupName:Bulbs,flowers

 :[{flowerCode:9,flowerName:Freesia},{flowerCode:11,flowerName:Lilies}]}]}

 [php output]

 var jsonObj = res.responseText.evalJSON(true);
 alert(jsonObj);

 will not even popup, on firebug no errors showing up.

 Kind regards
 Jason






 --
 Ryan Gahl
 CEO
 Nth Penguin, LLC
 http://www.nthpenguin.com
 --
 WebWidgetry.com / MashupStudio.com
 Future Home of the World's First Complete Web Platform
 --
 Inquire: 1-920-574-2218
 Blog: http://www.someElement.com
 LinkedIn Profile: http://www.linkedin.com/in/ryangahl




 --
 Ryan Gahl
 CEO
 Nth Penguin, LLC
 http://www.nthpenguin.com
 --
 WebWidgetry.com / MashupStudio.com
 Future Home of the World's First Complete Web Platform
 --
 Inquire: 1-920-574-2218
 Blog: http://www.someElement.com
 LinkedIn Profile: http://www.linkedin.com/in/ryangahl

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---