Questions tagged [json-serialization]

302 questions
1
vote
1 answer

Properties missing in JSON data deserialization with Model in .NET Core-6.0

my project is .NET 6.0. I have an issue After deserializing the JSON data with PriceVM class Show, Ticket fields are missing in the postman output. this is the JSON output without deserializing with model { "traceId":…
1
vote
1 answer

If a function uses "this", does invoking the function from a child class include the properties of the child class?

I create a class that includes a function to serialize itself to a JSON string using the "this" keyword, this class is then inherited by a child class. public class Parent { int a { get; set; } public ToJsonString() { return…
1
vote
1 answer

how can I use my to_json_string method to write the JSON string representation of a list of instances to a file

I have a base class: #!/usr/bin/python3 """Base class for all other classes in this module""" import json class Base: """Base Class Args: __nb_objects (int): number of instances of class """ __nb_objects = 0 def…
Marlon
  • 90
  • 6
1
vote
1 answer

Dictionary serialization: System.Exception: Type is not a dictionary

I have a dictionary in my type, which I want to get as input on controller: using Newtonsoft.Json; namespace LM.WebApp.Models.ApiModels; [JsonDictionary] public class Values { public Dictionary values { get; set; } } public…
1
vote
1 answer

How to serialize/deserialize enums in/from a lower case in Ktor?

I use Ktor serialization in my app, below is a dependency in build.gradle: dependencies { // ... implementation "io.ktor:ktor-serialization:$ktor_version" } And set up it in Application.kt: fun main(args: Array): Unit =…
Denis Sologub
  • 7,277
  • 11
  • 56
  • 123
1
vote
1 answer

How to use "pandas json normalize" to convert values as it is (as string)?

with some data, df = pd.DataFrame({ "data": [ {"a":1}, {"b":2.1} ] }) data 0 {'a': 1} 1 {'b': 2.1} expanding the dictionary in the column using .json_normalize: df2 = pd.json_normalize(df['data']) a b 0 …
1
vote
0 answers

JSON Converter changing case of values in netcoreapp3.1 web api

I have an enum extension that allows for enums to be transformed into their [Description] value, as in: private enum WithDescription { [Description("Nothing")] None = 0, [Description("Some of it")] Some, …
1
vote
2 answers

How I Put Data in Json FIle for a constractor property ? I get an error that Name ,Instructor, Credit can't access

public class students { public int ID { get; set; } public string fName { get; set; } public string mName { get; set; } public string lName { get; set; } public string Dept { get; set; } public…
1
vote
0 answers

How can I control the JSON serialization of an OpenApiExample object

We have an endpoint that returns a list of events. Each event can have a different type, but all events inherit the generic Event type. In order to correctly deserialize the events in our consumers we use serialize with these settings: new…
1
vote
1 answer

Serialize, deserialize complex object using jackson

I was trying convert to my object to and from json but the default serializer, deserializer by jackson doesn't work. How can I make this work? I understand I might need to write a custom serializer, deserializer. How can I do that? Is ther some…
1
vote
0 answers

dictionary with custom keys and values in Json.NET

I have a dictionary which uses classes for the keys and values. For those classes, I created JsonConverters to serialize/deserialize them in a specific way. To serialize the dictionary correctly, I used the following JsonConverter I found at…
1
vote
4 answers

Custom error response for incorrect json. Dotnet Core Web API

Is there a mechanism for returning a custom error response if an invalid type is given to a WebApi in Dotnet Core? E.G. if I have a class that looks like this public class SomeApiClass { public int Id { get; set; } } But make a post request…
scottdavidwalker
  • 1,118
  • 1
  • 12
  • 30
1
vote
1 answer

Django db field not displaying modified slug field value after serializing

I am trying get the user names instead of user id, in the created_by field of the Comment class. My model is below: class Comment(models.Model): thread_id = models.ForeignKey(Thread, on_delete=models.CASCADE) content = models.TextField() …
p s
  • 11
  • 1
1
vote
1 answer

How to remove backslash for quotes from JsonSchema?

I have a class: class Setting { String configurationName; String configuration; } I want to return the string representation how configuration will look like. This can be different object based on some conditions. In one of service I do…
MrSham
  • 539
  • 3
  • 8
  • 19
1
vote
2 answers

String ecoding returns wrong values . 33.48 becomes 33.47999999999999488

I'm trying to create a hash of a give object after converting it to string in swift but the values encoded returned in string are different. print(myObjectValues.v) // 33.48 let mydata = try JSONEncoder().encode(myObjectValues) …
Joe
  • 173
  • 1
  • 15