Response BodyAsJson with array does not work #401

Closed
opened 2025-12-29 08:27:26 +01:00 by adam · 4 comments
Owner

Originally created by @MarwaAloui on GitHub (Feb 8, 2022).

Hello, i want to configure the response of WirMock as BodyAsJson and inside i have an array of object

"Response": {
      "StatusCode": 200,
      "BodyAsJson": [
      {
          "ModelType": "XXX",
          "ModelNumber": "1"
      }
      ]
},

when i execute i have an error :
{ "Status": "Object serialized to Array. JObject instance expected." }

is it a bug?

Originally created by @MarwaAloui on GitHub (Feb 8, 2022). Hello, i want to configure the response of WirMock as BodyAsJson and inside i have an array of object ``` json "Response": { "StatusCode": 200, "BodyAsJson": [ { "ModelType": "XXX", "ModelNumber": "1" } ] }, ``` when i execute i have an error : `{ "Status": "Object serialized to Array. JObject instance expected." }` is it a bug?
adam added the bug label 2025-12-29 08:27:26 +01:00
adam closed this issue 2025-12-29 08:27:26 +01:00
Author
Owner

@StefH commented on GitHub (Feb 9, 2022):

@MarwaAloui
I tried to reproduce your error:

"Response": {  
      "StatusCode": 200,  
      "Headers": {  
        "Content-Type": "application/json"  
      },  
      "BodyAsJson": [  
        {  
          "id": 100,  
          "name": "Sofie",  
          "hasOwner": true,  
          "birthDate": "2019-12-05T11:00:30.573+01:00",  
          "animal": {  
            "id": 1,  
            "name": "Cat"  
          }  
        }  
      ]  
    }

However this works fine?
image

@StefH commented on GitHub (Feb 9, 2022): @MarwaAloui I tried to reproduce your error: ``` json "Response": { "StatusCode": 200, "Headers": { "Content-Type": "application/json" }, "BodyAsJson": [ { "id": 100, "name": "Sofie", "hasOwner": true, "birthDate": "2019-12-05T11:00:30.573+01:00", "animal": { "id": 1, "name": "Cat" } } ] } ``` However this works fine? ![image](https://user-images.githubusercontent.com/249938/153139302-0892498f-f9b0-4695-901e-ef57aeca04b7.png)
Author
Owner

@MarwaAloui commented on GitHub (Feb 9, 2022):

Thank you for your quick response
i retried without "UseTransformer": true, and it works well.

@MarwaAloui commented on GitHub (Feb 9, 2022): Thank you for your quick response i retried without "UseTransformer": true, and it works well.
Author
Owner

@StefH commented on GitHub (Feb 9, 2022):

I see.

I'll check the code.

@StefH commented on GitHub (Feb 9, 2022): I see. I'll check the code.
Author
Owner

@StefH commented on GitHub (Feb 9, 2022):

It's fixed.

A new version will be released soon.

@StefH commented on GitHub (Feb 9, 2022): It's fixed. A new version will be released soon.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#401