dotnet / WatsonWebserver

Watson is the fastest, easiest way to build scalable RESTful web servers and services in C#.
MIT License
411 stars 84 forks source link

[minor]Serialisation with Newtonsoft.Json failes - [JsonIgnore] is [System.Text.Json.Serialization.JsonIgnore] #102

Closed avogelba closed 1 year ago

avogelba commented 1 year ago

I used SimpleServer from your gh-page where, there it tries to serialize the request, but I failed badly. However I found out, if I take the source and do folowing changes it works...

For serialiazon add [Newtonsoft.Json.JsonIgnore] to all [JsonIgnore] occurances.

e..g in HttpResponse.cs:


        /// Response data stream sent to the requestor.
        /// </summary>
        [JsonIgnore]
        [Newtonsoft.Json.JsonIgnore]
        public MemoryStream Data
        {
            get
            {
                return _Data;
            }
        }

I have to add Newtonsoft nuget package then to use this attribute. Mabye there is a better solution within Newtonsoft to also use [System.Text.Json.Serialization.JsonIgnore].

If so let me know.

jchristn commented 1 year ago

Thanks for letting me know; I've amended the SimpleServer project to not use Newtonsoft any longer. Now it should serialize using System.Text.Json without issue.