Questions tagged [json-serialization]
302 questions
1
vote
1 answer
JSONSerialization formatting
I need help with JSONSerialization formatting.
func saveToJsonFile() {
guard let documentDirectoryUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
let fileUrl =…

alexsmith
- 199
- 2
- 10
1
vote
1 answer
How to do custom JSON serialization and deserialization in C#, when the object does not match the JSON
I have a class in the back-end of an asp.net application. This needs to be serialized to JSON and send to the front-end. This is no problem, except for the serialization. The class looks like this (class names and such are changed):
public class…

Martijn
- 739
- 9
- 26
1
vote
1 answer
TypeError: Object of type Decimal is not JSON serializable during Django data migration
I added a postgres JsonField in my model, and created data migration for it.
new_column = pg_fields.JSONField(default=dict, encoder=DjangoJSONEncoder)
Same logic is used for future data(in save() of model) and for historic data(data…

S.K
- 480
- 1
- 4
- 19
1
vote
1 answer
WCF REST service dictionary serialization
I'm having trouble with serializing dictionary in my WCF service.
[DataContract]
public class UserInfo
{
[DataMember]
public Guid ID { get; set; }
[DataMember]
public string Name { get; set; }
…

zhuber
- 5,364
- 3
- 30
- 63
1
vote
2 answers
How to parse a Java List of already parsed JSON into a Big JSON?
I use Jackson to serialize/deserialize JSON.
I have a List in which all elements inside are already serialized in JSON format. I would like to generate a big JSON from that List.
In other word, I have:
List a = new…

DaikonBoy
- 158
- 6
1
vote
2 answers
Create an empty list of arrays in Jackson
I'm using Jackson to serialize and deserialize JSON objects to and from POJO-s.
One of the elements I'm trying to create is a list of arrays (I think that's what this would be called).
"Images": [
{}
],
I've tried:
public ArrayList Images…

Anton
- 761
- 17
- 40
1
vote
1 answer
Specify class fields to be serialized to JSON in Ktor
Serving JSON content in Ktor as described in HTTP API - Quick Start - Ktor, as shown in the examples, works for common collections (lists, maps, etc.) and data classes. However, if I want to serialize a class that is not a data class and has fields…

Shreck Ye
- 1,591
- 2
- 16
- 32
1
vote
1 answer
Jackson Displaying fields in Json response
I am stuck with a problem which I have been trying to solve since last two days. I have an Integer object and a Float object which I do not want to display in the JSON response if it is 0. I am trying to achieve this with…

Amith Rampur
- 15
- 5
1
vote
1 answer
Kotlin - Serialize JSON Array to multiple classes
I'd like to parse JSON Array(in String) to Kotlin Array of multiple classes. Is it possible to do serialization like below? I'm using kotlinx.serialization, but can use other libraries if needed.
abstract class DataTypeBase(val dataType:…

rhythm
- 469
- 9
- 24
1
vote
0 answers
Nancy: configure per-request MaxJsonLength and other json serialization settings
I would like Nancy's Json serialization to behave as usual for a certain set of requests.
For other (very particular!) requests, usually for diagnostic purpose, I'd like to be able to get very specific settings, such as MaxJsonLength set to…

Starnuto di topo
- 3,215
- 5
- 32
- 66
1
vote
2 answers
rails 5.2 improper json serialization for application record
model
class PushNotificationRequest < ApplicationRecord
serialize :details
migration
class CreateNotificationRequests < ActiveRecord::Migration[5.2]
def change
create_table :notification_requests do |t|
t.references :order,…

t0il3ts0ap
- 530
- 4
- 18
1
vote
1 answer
How to serialize a map with enum keys in declaration order with JSON?
I have some enum class, let's imagine
public enum MyEnum {
ONE("one"), TWO("two"), THREE("three"), DEFAULT("some value")
//..
}
and Dto class:
@JsonPropertyOrder(value = {"id", "name", "params"})
public Dto {
private Long id;
…

Nikolas
- 2,322
- 9
- 33
- 55
1
vote
1 answer
Generalising JSON response as function parameter
JSON Serialization :
var responseDict: [AnyHashable : Any]? = nil
if let anEncoding = responseString?.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue)) {
responseDict = try! JSONSerialization.jsonObject(with: anEncoding,…

Nitish
- 13,845
- 28
- 135
- 263
1
vote
1 answer
Jackson Object Mapper not working when extended configuration provided but working when providing class level/field level annotations in Spring Boot
The below object mapper configuration is not working when I add jjwt security to spring boot application.
@Configuration
public class CustomObjectMapper extends ObjectMapper {
/**
* Default serial version id generated.
*/
private static final…

Visanth Rajamohan
- 11
- 3
1
vote
0 answers
unable to access json server
I created a mock json server and trying to open in browser ,landing in the following error:
events.js:167
throw er; // Unhandled 'error' event
^
Error: listen EACCES 127.0.0.1:8000
at Server.setupListenHandle [as _listen2]…

Mohammed Ajmal
- 570
- 1
- 7
- 20