[SalesForce] System.JSONException: Unexpected character (‘}’ (code 125))

I am passing the below JSON structure using POST method to a apex service:

I get an error at line where the codes variable ends

{
"PId" : "345",
"Description" : "test",
"Codes" :[
    {
    "Code" : " ",
    "qw" : " ",
    "qwe" : " ",
    "Desc" : " ",
    "RT": " ",
    } ], <- Error at this line 
"AccountName" : "Account 001",
"AccountNumber" : "123333" ,
"Address" : "NY",
} 

Error:

System.JSONException: Unexpected character ('}' (code 125)): was
expecting double-quote to start field name at [line:14, column:3]

Am I forming the JSON correctly ?

Best Answer

The trailing "," is not allowed. The final element in an object or array must not have a comma after it.

{
"PId" : "345",
"Description" : "test",
"Codes" :[
    {
    "Code" : " ",
    "qw" : " ",
    "qwe" : " ",
    "Desc" : " ",
    "RT": " "
    } ],
"AccountName" : "Account 001",
"AccountNumber" : "123333" ,
"Address" : "NY"
} 
Related Topic