Skip to content
Advertisement

JSON Error “java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $”

JavaScript

This create Exception

JavaScript

Big thanks for help.

Advertisement

Answer

Let’s look at the error you are receiving.

Expected BEGIN_OBJECT

Your JSON is an object, and all JSON objects are enclosed in curly braces ({}). BEGIN_OBJECT is therefore {. And it’s expecting it somewhere.

but was STRING

But instead he found a string “Something”. Still doesn’t tell us where.

at line 1 column 1 path $

Ah, perfect. At line 1 column 1. Which is the start of the JSON. So you have forgotten to enclose the whole thing in {} (or at least you have forgotten the first one, but I bet you’ve forgotten them both).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement