Fix memory leak in json load and storage.