1 post / 0 new
Last post
#1

Use null instead of "" (empty string)

Sun, 10/23/2011 - 15:58

A recommendation/suggestion is that when serving empty values for something like shipping.nextDay you should use null instead of an empty string like "". So instead of shipping:{nextDay:""} ... I would recommend generating shipping:{nextDay: null} ... You may wonder why? Well this is a critical best-practice for anyone who needs to process the product archives on full-text search solutions like ElasticSearch. Any such solutions will tend to leverage JSON's reflective data-type determination properties to figure out how to treat data therefore removing the need to specify a schema. This is all blown away with an empty string "" for various reasons ... whereas having a null gets treated properly and the attribute gets ignored as it should be. If this is something that you intend to implement as a best-practice in the archives and API stream eventually or if it is already on the cards or roadmap somewhere, please do tell :)

blog comments powered by Disqus