Перейти к основному содержимому

How to fix JSON config errors in Counter-Strike 2 plugins

Most CounterStrikeSharp and SwiftlyS2 plugins on Counter-Strike 2 servers store their settings in JSON files. JSON is very strict — one extra or missing comma is enough for the plugin to ignore the whole file.

Symptoms​

  • A plugin stops working right after you edited its config.
  • Errors like these in the console or in game > csgo > addons > counterstrikesharp > logs:
Error reading or deserializing GGMCmaps.json file: The JSON object contains a trailing comma
at the end which is not supported in this mode. LineNumber: 199 | BytePositionInLine: 0.
'}' is invalid after a value. Expected either ',', '}', or ']'. LineNumber: 12

The error tells you the file and the line number where the problem is.

The most common mistakes​

MistakeWrongCorrect
Trailing comma after the last item{ "a": 1, "b": 2, }{ "a": 1, "b": 2 }
Missing comma between items{ "a": 1 "b": 2 }{ "a": 1, "b": 2 }
Single quotes{ 'map': 'de_dust2' }{ "map": "de_dust2" }
Comments in a .json file"a": 1 // commentRemove the comment (only .jsonc files allow comments)
Missing bracket at the end{ "maps": [ "de_dust2" }{ "maps": [ "de_dust2" ] }
Text values without quotes"mode": competitive"mode": "competitive"

The trailing comma is the most common one. It usually happens when you delete the last item of a list and forget the comma of the item before it:

{
"Maps": [
"de_dust2",
"de_mirage",
"de_inferno",
]
}

Here the comma after "de_inferno" must be removed.

How to fix it​

Step 1) Go to your console, go to "FILE MANAGER" and open the file from the error message.

Step 2) Go to the line number from the error. The mistake is on that line or on the line just before it.

Step 3) To check the whole file, copy its content and paste it into a JSON validator such as jsonlint.com. It shows the exact position of every mistake.

Step 4) Fix the mistake, save the file and reload the plugin with css_plugins reload PluginName — or restart the server.

TIP

Before you edit a config, download a copy of it. If something goes wrong, you can upload the working version back.