HIVE_CURSOR_ERROR: Row is not a valid JSON Object - JSONException: A JSONObject text must end with '}' at 2 [character 3 line 1]

0

I am storing below json file in S3 bucket after partitioning using firehose:

{"topic": "ad","timestamp": 1718465649,"ad": {"id":"8e9e5198-baec-4c7d-9372-cf5744a66789","uid":"19a16a01-9e62-40fe-a93c-665e6da51bb6"},"browser": {"user_agent": "Mozilla/5.0 (Linux; Android 13; SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36"}}

When I try to read this data using Athena, I am getting below error: HIVE_CURSOR_ERROR: Row is not a valid JSON Object - JSONException: A JSONObject text must end with '}' at 2 [character 3 line 1]

What is the correct format of json for my data?

asked 3 months ago354 views
1 Answer
1

Hello.

Are the contents of the JSON file registered one line for each object?
https://repost.aws/knowledge-center/error-json-athena

In other words, if there is not a line break for each object in the file as shown below, such an error may occur.

{"topic": "ad","timestamp": 1718465649,"ad": {"id":"8e9e5198-baec-4c7d-9372-cf5744a66789","uid":"19a16a01-9e62-40fe-a93c-665e6da51bb6"},"browser": {"user_agent": "Mozilla/5.0 (Linux; Android 13; SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36"}}
{"topic": "ad","timestamp": 1718465649,"ad": {"id":"8e9e5198-baec-4c7d-9372-cf5744a66789","uid":"19a16a01-9e62-40fe-a93c-665e6da51bb6"},"browser": {"user_agent": "Mozilla/5.0 (Linux; Android 13; SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36"}}
profile picture
EXPERT
answered 3 months ago
profile picture
EXPERT
reviewed 3 months ago
EXPERT
Leo K
reviewed 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions