Serialize property with json

I am returning a dto like

public class RawData
{
		
	[DataMember(Name = "version")]
	public string Version { get; set; }
		
	[DataMember(Name = "message")]
	public string Message { get; set; }

	[DataMember(Name = "archive_url")]
	public string ArchiveUrl { get; set; }

}

The property Message should return a stored Json string in the database. However when I put the Json text inside the Message property, this is of course escaped like a string.

Is there an attribute I can put on the Message property, so that it will be serialized exactly like it is in the database.

{
  "version": "12",
  "Message": { "name": "product", "price": 2.01 },
  "ArchiveUrl": "https://localhost:5000/product/11111"
}

So basically the { "name": "product", "price": 2.01 } is the exact string in our database that I want to return as the result of a serialization of the Message property.

Thx

You can’t return a JSON object in a string property.

You should always prefer typed properties in DTOs like Dictionary<string,string>.

If you want to return any arbitrary object you can change it to an object populated with JSON.parse(json) but there’s several issues with objects & unknown types in DTOs & should be avoided, it’s ok if this API is not intended to be consumed from typed service clients where it’s not supported.

It is a third party system, nothing to do with ServiceStack that needs a response like this.
I tried, but if I change my Message property to Object, assign it the Json string, it still is making it an escaped string of it. "Message": "{ \"name\": \"product\", \"price\": 2.01 }",

Ok found it.
Created a JsonOutputType class with a Value property of String.
Assigned the raw json string to this value.
Used that type in my Dto instead of String (or object).
Then added JsConfig<JsonOutputType>.RawSerializeFn = c => c.Value;. This works like I needed it.

I said you could change to an object populated with JSON.parse(json), e.g:

return new RawData {
    Message = JSON.parse(json)
}

So it serializes the JS Object dictionary, not a JSON string.

Ok sorry for not understanding.

Have a nice day too.