Added flexibility to JSON item structure

Simplified code and improved flexibility. See change comments.