Fixed index_to_json method