properly extracts JSON data