Fix bug in json logic