Questions tagged [json-serialization]
302 questions
0
votes
1 answer
How to serialize a JSON file with tree structure with Jackson
I need to serialize a JSON file to a Java object. The JSON file has a tree structure, which means that the object at the root has children that are instances of itself and so on. For example, consider the following JSON file:
{
"name": "peter",
…

cesarsotovalero
- 1,116
- 6
- 15
0
votes
0 answers
Json.Net - adapt dictionary key serialization for single property
I'm using a DefaultcontractResolver with CamelCaseNamingStrategy to serialize my dictionaries. For reasons outside my control, I temporarily have to serialize a single dictionary to PascalCase. Yet, I can't seem to get it to work.
I set up my…

Stephan Steiner
- 1,043
- 1
- 9
- 22
0
votes
1 answer
Concat names of nested values of a json file in c# ex: ` "obj_nested1_nested2" : "text"
I'm looking for a way to transform this c# object:
class BaseClass
{
public string Value1 {get; set;}
public NestedObject nestedObject {get;set;}
}
class NestedObject
{
public string NestedValue1 {get; set;}
}
Into this json:
{
…

nku jomiru
- 11
- 1
0
votes
2 answers
How to pass "unknown" object as parameter and use it's original object type to deserialize
I am working on building a re-usable function to deserialize a JSON string.
The JSON deserialization routines need an object type(jsonTestObject). This all works as expected.
// serialize json to object
jsonTestObject testO = new…

Louis van Tonder
- 3,664
- 3
- 31
- 62
0
votes
2 answers
JSON serialization - how not to serialize one class property with the whole structure
I want to serialize some string json (I use Spring Boot):
{
"commandId": "34d3a914-a3d7-112a-bs37-3452ac130002",
"status": "SUCCESS",
"response": {
"prop1": "",
"prop2": "",
"prop3": "true",
"prop4": ""
}
}
My…

Matley
- 1,953
- 4
- 35
- 73
0
votes
1 answer
Java multi-schema generator using annotations
I have a series of inter-related Java classes which form a super-set of possible schema. I'm looking for some way to annotate/tag individual fields such that I can create separate JSON schema for each 'namespace'.
A simple example:
class…

Noxville
- 544
- 3
- 15
0
votes
1 answer
Decode nested JSON arrays and dictionaries in Swift using Structs with JSONserialization
I am trying to create some structs to decode some JSON received from an API using JSONSerialization.jsonObject(with: data, options: [])
This is what the JSON looks like:
{"books":[{"title":"The Fountainhead.","author":"Ayn Ranyd"},{"title":"Tom…

zztop
- 701
- 1
- 7
- 20
0
votes
1 answer
Parsing nested JSON in Swift compared with Objective-C
I am trying to parse some JSON in Swift that I was previously parsing in Objective-C and am having some difficulties.
In objective-C I was able to parse it simply enough using:
NSError* error;
NSDictionary *jsonResults = [NSJSONSerialization…

zztop
- 701
- 1
- 7
- 20
0
votes
1 answer
How to serialize/ deserialize via jackson when class contains variables of type interface?
There's an interface, let's say A. I have multiple classes that implements that interface A. Those classes also consists of class variable of type A. So, it's like:
@JsonTypeInfo(use = JsonTypeInfo.Id.Class, include = JsonTypeInfo.As.Property,…

TCodeMav
- 3
- 3
0
votes
0 answers
Swift Post request parameters without the double quote marks
My current code looks like this and request httpBody I'm sending is also there
let params: [String: Any] = [
"user_id": defaults.object(forKey: "userID") as! Int,
"opid": opid
]
guard let url = URL(string:…

K. Mitra
- 483
- 7
- 17
0
votes
0 answers
How can I serialize and deserialize list of my custom type in correct way in Python json?
This is my custom type
class Student:
def __init__(self, name, surname, pid, institute, profession, group, educationalLevel, age, gpa):
self.name = name
self.surname = surname
self.pid = pid
self.institute =…

Foo Boy
- 9
- 4
0
votes
2 answers
Projecting list of objects into another type by JsonProperty attribute value
I have the following models:
class CheckResponse
{
public ICollection Checks { get; set; }
}
public class CheckModel
{
[JsonConverter(typeof(StringEnumConverter))]
public CheckCodes CheckCode { get; set; }
…

Dmitry Stepanov
- 2,776
- 8
- 29
- 45
0
votes
1 answer
Serialize java.nio.file.Path with JsonBuilder in Groovy
I am trying to serialize an object which holds an instance of java.nio.file.Path and since path is an interface I am receiving a StackOverflow Exception
I have checked this answer: https://stackoverflow.com/a/36966590/11325201
and wanted to…

Ethan K
- 131
- 1
- 9
0
votes
0 answers
How can I stop Dart Analyser complaining about type mismatch between json_serializable and dart::convert when implicit casting is turned off?
I have the following in my analysis_options.yaml:-
analyzer:
strong-mode:
implicit-casts: false
When I use the json_serializable and generate to 'fromJson' method, and try to pass, the result from jsonDecode (from base dart::convert package),…

parkeradam
- 11
- 2
0
votes
2 answers
Scala: How serialize data in JSON?
I recently started to learn Scala. I need an EASY way to SERIALIZE my data in Json. Below I will give an example of data. I tried several popular libraries: GSON, Play JSON, Circe, but did not get the result! GSON does not know how to work with…

GranmaSquid3
- 25
- 4