Render null data

17 views
Skip to first unread message

Jeroen Knoef

unread,
Jul 19, 2017, 10:02:30 AM7/19/17
to framework-one
Hi,

I'm using FW/1 for a REST API (json), and on some of the requests a simple 'null' should be returned.
According to this SO answer, which includes references, null as well as any other json value is valid json by itself.

SerializeJSON() supports this is well. FW/1's renderData API however does not.

I've got a change ready for review, with these additions:
- json nulls are rendered as 'null'
- html nulls are rendered as ''
- xml nulls throw FW1.UnsupportXMLRender


If you consider this a good idea, I will of course submit a PR for further review/discussion.

Thanks!
Jeroen

Sean Corfield

unread,
Jul 19, 2017, 5:04:06 PM7/19/17
to framew...@googlegroups.com
I don't think you can (portably) remove a default argument value (on data) when there are defaulted arguments to the left (type). Otherwise it seems reasonable on the surface (although it's a lot of repetitive code so I suspect there's a better way to do it).

I don't think I'll entertain a PR for it as-is but if you create an issue on GitHub we can discuss use cases and I can review the code to see if there's a better way to produce null for JSON, without so much conditional code.

--
FW/1 documentation: http://framework-one.github.io
FW/1 source code: http://github.com/framework-one/fw1
FW/1 chat / support: https://gitter.im/framework-one/fw1
FW/1 mailing list: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-one+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/framework-one.
For more options, visit https://groups.google.com/d/optout.



--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
Reply all
Reply to author
Forward
0 new messages