Added JSON template function to handle complex data.