JSON returned is a different format than expected;

59 views
Skip to first unread message

Lisel Jensen

unread,
Jan 17, 2014, 12:55:02 PM1/17/14
to taffy...@googlegroups.com
The JSON Taffy is returning is in the following format:

{
   "COLUMNS": [
      "SKU",
      "ITEM_DESCRIPTION",
      "BRAND_DESCRIPTION"
   ],
   "DATA": [
      [
         "79548200274531",
         "
Preferred1",
         "Restaurants1"
      ],
      [
         "84348200274630",
         "
Preferred2",
         "Restaurants2"
      ],
      [
         "98448200274647",
         "Preferred3",
         "Restaurants3"
      ]
]
}

Rather than something like:
{"PRODUCTS": [
{ "SKU":"79548200274531" , "ITEM_DESCRIPTION":"Preferred1", "BRAND_DESCRIPTION":"Restaurants1", },
{ "SKU":"84348200274630" , "ITEM_DESCRIPTION":"Preferred2", "BRAND_DESCRIPTION":"Restaurants2", },
{ "SKU":"98448200274647" , "ITEM_DESCRIPTION":"Preferred3", "BRAND_DESCRIPTION":"Restaurants3", }
] }

Is the first example the format it is expected to come back in? And, is there a way to get it to return in the second format?

Thanks!

Adam Tuttle

unread,
Jan 17, 2014, 1:04:29 PM1/17/14
to taffy...@googlegroups.com
That's what ColdFusion does by default when you serialize a query. Taffy 1.3+ includes a helper method that you can use to convert to the more sane format that you suggest:


Basically: return representationOf( queryToArray( yourQuery ) );

Also note that queryToArray will preserve the key capitalization from the SQL statement instead of upper-casing everything (a common complaint about serializeJSON). If you do "select SKU..." you'll get {"SKU":...} whereas if you run "select sku..." you'll get {"sku":...}.

Adam


--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Matt Quackenbush

unread,
Jan 17, 2014, 1:08:23 PM1/17/14
to taffy...@googlegroups.com
Another example of why Taffy == awesomesauce. :-)

Lisel Jensen

unread,
Jan 17, 2014, 1:10:36 PM1/17/14
to taffy...@googlegroups.com
Beautiful!! Thanks for the quick response!

Joseph Higgins

unread,
May 2, 2014, 5:30:54 PM5/2/14
to taffy...@googlegroups.com
How do you then add totalcount for extjs grids that is needed outside the query?

Adam Tuttle

unread,
May 4, 2014, 9:30:06 PM5/4/14
to taffy...@googlegroups.com
You could add a header with the total count and, if necessary, the current offset. Not sure what you're using on the front-end or what it expects.

Adam


On Fri, May 2, 2014 at 5:30 PM, Joseph Higgins <higg...@gmail.com> wrote:
How do you then add totalcount for extjs grids that is needed outside the query?

--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages