Formatting JSON Output

83 views
Skip to first unread message

Brian

unread,
Jan 28, 2013, 4:53:42 PM1/28/13
to res...@googlegroups.com
Hi all,

One of the needs I ran into with restify was fine-grained control of the output of JSON send to clients. Most REST API's query a data store, filter specific objects and then send some representation of those objects back to the client. The exact model objects returned from the data store are rarely formatted properly for client consumption. You almost always need to white list certain properties or add additional meta data. Those tasks are always the same. Public user objects should always look like public user objects regardless of the API endpoint outputting them.

As a solution, we have come up with Jiggler, a lightweight framework for defining object representation templates and then transforming model objects via those templates: 


I'd love to more seamlessly integrate Jiggler with Restify and am curious what approach would be best. My intended approach is to add the to-be-transformed object to the request and then add a post-route-definition plugin that tells Jiggler to format that object as the response (so that this function executes after all business logic). Any thoughts on this or possible better alternatives?

Thanks! 

Mark Cavage

unread,
Jan 28, 2013, 8:35:05 PM1/28/13
to res...@googlegroups.com

Hi Brian,

I'm on the road some this week, but I'll look at your code and get back to you.  This sounds fantastic though from your description :-)

m

--
You received this message because you are subscribed to the Google Groups "restify" group.
To unsubscribe from this group, send email to restify+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Brian Romanko

unread,
Jan 28, 2013, 9:20:34 PM1/28/13
to res...@googlegroups.com
Look forward to it. Enjoy your trip. Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to restify+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages