Yii2 Rest API returns json array extra comma?

Hi Guys,

I am using Yii2 activeController for building REST API, Where the results is returning JSON format which has extra comma (,) in multidimensional arrays!.

Any idea how to remove this?

Example output is as follows

{"groups": {

      "Quaasdfaest": {

        "headers": [

          "Subject Name",



          "FA + SA"


        "rows": [


            "Subject Name": "asdfasdfasd",

            "Forasdfasdfent": "E1",

            "Sumfoooent": "E2",

            "FA + SA": "E1"



            "Subject Name": "asdfasdfasdfasd",

            "Foasdfasdfasdfasdment": "-",

            "Sumasdfasdfasdfssment": "-",

            "FA + SA": "-"


        ], //Extra comma comes here at the end!



It seems php normal json_encode also did the same!. Is it possible we can overwrite through Yii2 ?

Which function returns such JSON?

Standard json_encode doesn’t produce extra comma (I have just tested it)

Hi Phantomlord,

Thanks for your reply!. I didn’t use any encoding myself. I just simply return as array format because my controller extends activecontroller of Yii2 for REST API.

I hope by default it is using json_encode.

it is likely your array/list contains that extra comma