Hello,
I currently have a model with the following inputs:
Hours of Operation (Schema)
Monday (Input)
Tuesday (Input)
Wednesday (Input)
Thursday (Input)
Friday (Input)
Saturday (Input)
Sunday (Input)
When attempting to create a new content piece for it using the client library. It fails due to the JsonConverter not following the case of the attribute. So when created “Monday” is changed to “monday”.
Am I using the wrong approach here?
No, it is by design. See:
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Squidex.ClientLibrary
{
public static class HttpClientExtensions
{
private static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
public static HttpContent ToContent<T>(this T value)
{
var content = new StringContent(JsonConvert.SerializeObject(value, Formatting.Indented, SerializerSettings), Encoding.UTF8, "application/json");
return content;
}
You can use the JsonProperty attribute or I can create an extension in the Client Library for you.
Awesome thank you. Appreciate that.