Questions tagged [json-serialization]

302 questions
0
votes
0 answers

Java Jackson ObjectMapper Inheritance issue

public interface Vehicle { public default String getFourWheel() { throw new RuntimeException("Four Wheel not applicable"); } public default String getTwoWheel() { throw new RuntimeException("Two Wheel not applicable"); …
Hamid
  • 717
  • 7
  • 15
0
votes
1 answer

_InternalLinkedHashMap' is not a subtype of type 'String'

Will @JsonSerialization take care of the List mapping if there exists a List in Flutter? @JsonSerializable() class Content { Content(this.contentItems); @JsonKey(name: "content-items") List contentItems; factory…
Abraham Mathew
  • 2,029
  • 3
  • 21
  • 42
0
votes
1 answer

Cannot Deserialize JSON String in C#

I have the following models: public class InputFile { public string Path { get; set; } // absolute path of file public string Content { get; set; } // full content of the json file } and public class InputModel { public List
0
votes
0 answers

Json sterilization does not work for complex object with TypeConverter attribute

I have created a class name as TFDisplay, a [TypeConverter()] attribute applied on it. When I call JsonConvert.SerializeObject(tfdisplayInstance), it does not sterilize the entire class object as Json sting, instead it considers only one property of…
Neeraj Kumar Gupta
  • 2,157
  • 7
  • 30
  • 58
0
votes
1 answer

Spring filtering response fields with jackson

I am trying to filter fields in a nested object: class Response { // These objects themselves can have many fields within private final PropA a; private final PropB b; @JsonCreator public Response(PropA a, PropB b) { ... } } I'd like a…
theartv
  • 35
  • 7
0
votes
1 answer

Serialize/Deserialize simple but nested object to/from JSON

I'm trying to transmit a Config from client to server. Config contains a password key I must NOT transmit Config contains a couple of simple objects, which are just key/value pairs (with value being a basic primitive) This code works: class…
P i
  • 29,020
  • 36
  • 159
  • 267
0
votes
1 answer

fromJson throws Expected a value of type 'Map', but got one of type '_JsonDocumentSnapshot'

I'm trying to use json_serializable:. my pubspec.yaml dependencies: json_annotation: 3.1.1 dev_dependencies: build_runner: json_serializable: 3.5.1 my stream from Firestore static Stream> getOrderById(String docId)…
Kerem
  • 840
  • 7
  • 22
0
votes
0 answers

.NET Core 2.2 vs 5.0 IActionResult "NotFound" Serialization

In .NET Core 2.2 returning NotFound() in a WebAPI controller like this: [HttpGet] public IActionResult DoSomething() { return NotFound(new IOException("Unable to locate specified resource.")); } would respond with a 404 status code with JSON in…
Xorcist
  • 3,129
  • 3
  • 21
  • 47
0
votes
0 answers

Newtonsoft JSON serialization - how to flatten a reference type field

I have a class (MyClass), in which there is a reference type field (let's call MyNestedClass). I'm using Newtonsoft, and I would like to serialize this class, including this field. But instead of "opening a new block" in the Json (a Json object), I…
0
votes
1 answer

Can't not pass a Json Array as body in Restassured request - java.lang.IllegalStateException: Not a JSON Object

I am trying to pass a list of objects as body in a restassured request: Transaction transaction1 = new Transaction(); Transaction transaction2 = new Transaction(); List transactionList = new…
0
votes
2 answers

Mapping an Object with variable name in Jackson

I have the following JSON: { "filebeat": { "version": 2, "modified_date": "2021-01-15T14:02:41.103Z", "policy": { "phases": { "hot": { "min_age": "0ms", "actions": { "rollover": { …
Homewrecker
  • 1,076
  • 1
  • 15
  • 38
0
votes
2 answers

Symfony 5 Serializer - How to not expose whole database

We use the Symfony Serializer to convert some Doctrine objects to JSON, goal is to provide them as results of API calls. Out data model has about thirty classes, all are somehow linked with each other and the Doctrine model reflects this. So…
Ralf Jahr
  • 312
  • 2
  • 18
0
votes
1 answer

Jackson serializer for ValueObject hierarchy - polymorphic

As a continuation of jackson-serialize-simple-one-attribute-valueobject-like-enum-without-nesting I would like to be able to create Wrapping one attribute ValueObjects in a very simple manner, just by inheriting from base ValueObject…
bastiat
  • 1,799
  • 2
  • 19
  • 38
0
votes
0 answers

How to JSON Serialize a List with Extension in C#

public class ParentData :ObservableRangeCollection { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } } public class ChildData { public string ChildName { get; set; } public…
MainakChoudhury
  • 502
  • 1
  • 7
  • 23
0
votes
1 answer

How can I reflect this kind of JSON array by Run Time Type Reflection (RTTR)?

I want to reflect a JSON string like the following to a single std::vector: [ { "X": 113.80403039339605, "Y": 22.652868779963439, "Z": 113.80403039339605 }, { "X": 113.80403464036024, "Y": 22.652860696903234, "Z": 113.80403464036024 } ] The…
cowboylym
  • 13
  • 3