Jump to content

need help with json adding


Recommended Posts

can someone help me and tell me why on earth the VS on this lines

JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(new JsonSerializerSettings
            {
                Formatting = 1,
                ObjectCreationHandling = 2
            });

gives me this errors

error CS0266: Cannot implicitly convert type 'int' to 'Newtonsoft.Json.Formatting'. An explicit conversion exists (are you missing a cast?)
error CS0266: Cannot implicitly convert type 'int' to 'Newtonsoft.Json.ObjectCreationHandling'. An explicit conversion exists (are you missing a cast?)

how to repair this? 

28 minutes ago, Zoom12 said:

can someone help me and tell me why on earth the VS on this lines


JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(new JsonSerializerSettings
            {
                Formatting = 1,
                ObjectCreationHandling = 2
            });

gives me this errors


error CS0266: Cannot implicitly convert type 'int' to 'Newtonsoft.Json.Formatting'. An explicit conversion exists (are you missing a cast?)
error CS0266: Cannot implicitly convert type 'int' to 'Newtonsoft.Json.ObjectCreationHandling'. An explicit conversion exists (are you missing a cast?)

how to repair this? 

Typed language wants types.

Formatting = Newtonsoft.Json.Formatting.Indented,
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore

As an example.

Your ObjectCreationHandling will have its own type to look for.

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...