[Solved] How to fix json error Expecting ‘STRING’, got ‘}’ [closed]

Introduction

If you are working with JSON data and you encounter the error “Expecting ‘STRING’, got ‘}'”, you may be wondering how to fix it. This error occurs when the JSON data is not properly formatted. In this article, we will discuss the causes of this error and how to fix it. We will also provide some tips to help you avoid this error in the future. By the end of this article, you should have a better understanding of how to fix this error and how to prevent it from occurring again.

Solution

The most likely cause of this error is that you have an extra closing curly brace somewhere in your JSON code. Check your code for any extra closing curly braces and remove them. If you are using a JSON validator, it should be able to point out the exact location of the extra closing curly brace.


After looking at the data, it looks like their are two problems.

  1. Your collection of orders and items are not closed.
  2. The main json object is not closed.

Let’s start with the Order and Item collection:

Order and Item Problem Area

The item collection in the order with recordId 3 is not closed properly. This is resulting in the order with recordId 4 being a child of record 3’s items. Additionally there is no closure to the order record itself (missing curly braces).

To fix this, place a square brace, then a curly brace, before the comma, at the end of the item properties.

How to Fix Order

Resulting in:

Fixed Orders

Now that we have the orders cleaned up, there are just a couple braces at the end of the file that need to be closed.

The order collection is missing its closing square brace, and the main json object is missing its closing curly brace:

Missing Closing Braces

Resulting in:

Fixed Closing Braces

So, this fixes the structural issues. As @Gixabel mentioned, you also need to enclose all the instances of shipDate as stings, since they are representations of dates.

1

solved How to fix json error Expecting ‘STRING’, got ‘}’ [closed]


If you are getting an error that says “Expecting ‘STRING’, got ‘}'” when trying to parse a JSON string, it means that the JSON string is not properly formatted. The error is telling you that the parser is expecting a string value, but instead it got a closing curly brace. This usually means that there is a missing opening curly brace somewhere in the string.

To fix this error, you need to find the missing opening curly brace and add it to the string. You can use a text editor or an online JSON validator to help you find the missing brace. Once you have found the missing brace, add it to the string and try parsing the JSON string again. If the error persists, you may need to check the rest of the string for any other syntax errors.

If you are still having trouble, you can post your JSON string in a forum or ask for help from a developer. They should be able to help you find and fix the error quickly.