Questions tagged [json-serialization]

302 questions
2
votes
3 answers

How to serialise Object to JSON in Unity

I am trying to serialise a huge Class with nested classes, AudioClip and texture2D. I implemented ISerializable interface and marked all classes with SerializableAttribute. I use JsonUtility to convert to Json and back. Everything works well except…
Blaser
  • 35
  • 1
  • 7
2
votes
1 answer

JIL json serializer does not serialize properties from derived class

JIL json serializer does not serialize properties from derived class Below are the code snippet: public async Task WriteAsync(OutputFormatterWriteContext context) { if (context == null) { throw new…
Nayan Rudani
  • 1,029
  • 3
  • 12
  • 21
2
votes
3 answers

PHP Serialization with private attributes & getters & setters

I have a base class which uses php magic methods __get and __set to be able to modify private attributes in the extended class. Then I built setter getter functions for the relevant private attributes (similar to what is found here…
Gotts
  • 2,274
  • 3
  • 23
  • 32
2
votes
1 answer

Newtonsoft JSON: TypeNameHandling - $type purpose

What is the main purpose (or advantage) of having $type value generated in JSON data? Does it simplify deserialization in some way? I enabled this by setting TypeNameHandling property of (de)serializer, because my intent was to have a strong…
2
votes
2 answers

Json formatting with Json.net in C#

I am trying to parse a bunch of XML files into a single JSON file, which is already working. The final JSON file looks like the following: { "items": [ { "subItems": [ { "Name": "Name", …
SaraFlower
  • 755
  • 1
  • 8
  • 15
2
votes
1 answer

F# deserialize a JSON string into correct record type

The scenario is - receiving a JSON string from the network and deserializing it into correct corresponding record type. JSON string can be either: (1) "{"a":"some text"}" or (2) "{"b":1}" Values might differ, but the format of fields will either be…
2
votes
1 answer

Rest: Sending List of Enums does not send all data

1. BACKEND In my backend (SpringBoot) I am sending list of enums: @RequestMapping("getMyEnum") public List getMyEnum() { return Arrays.asList(MyEnum.values()); } Here is MyEnum: public enum MyEnum { A("bla1"), B("bla2"); …
Tomas Marik
  • 4,053
  • 3
  • 31
  • 62
1
vote
0 answers

Flutter How to make a class only accessible to another class?

I'm using json_serializable package to convert json into object. Below is my json { "name": "foo bar", "age": 10, "favouriteFood": [ { "id": 0, "food": "banana" }, { "id": 1, …
ramen87x
  • 160
  • 3
  • 18
1
vote
2 answers

Save data in Json flutter

I'm trying to build a sudoku application in flutter but the problem is it needs a continue button in it but I don't know how to save current played game data in the Json. class GameController extends GetxController { Timer? _timer; int…
Adeen
  • 11
  • 2
1
vote
1 answer

What ColdFusion server settings can affect superagent 'get' content types?

Our shop is running two Adobe ColdFusion servers, a development and a production. Production is on ColdFusion 2018 and development is on ColdFusion 2021. When upgrading the development server to 2021, we chose to migrate the server administrator…
1
vote
1 answer

System.Text.Json Custom JsonConverter Write() never called

I have a .NET 6 solution for which I'm trying to override the default format of DateTimeOffset's when calling JsonObject.ToJsonString(). This is all using the native System.Text.Json libraries. I've added a custom DateTimeOffsetConverter: public…
Gavin
  • 5,629
  • 7
  • 44
  • 86
1
vote
1 answer

Can I configure asp.net so some responses are serialized as camelCase and some as PascalCase?

I have an API with two clients: OldClient and newClient. I currently have this in Startup.cs so my json responses are serialized as PascalCase, i.e. as per all my .net objects which have first letter capitalized. …
Rory
  • 40,559
  • 52
  • 175
  • 261
1
vote
1 answer

Equatable package can not extends class - Flutter

I am using an extension name Dart data class generator and I allow it to use equatable package but for some reason it gave me this error The error on the import line is :"Unused import: 'package:equatable/equatable.dart'. Try removing the import…
Ken
  • 57
  • 6
1
vote
0 answers

Serialization of google storage response object to json

import com.google.api.gax.paging.Page; import com.google.cloud.storage.Bucket; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; public class ListBuckets { public static void listBuckets(String projectId) { …
1
vote
1 answer

Use JsonProperty if it exists otherwise use camelcase

I have the following class: public sealed class CRMUser { /// The display name. /// [JsonProperty("name")] public string DisplayName { get; set; } [JsonProperty("email")] public string EmailAddress { get; set; } …
Pete
  • 57,112
  • 28
  • 117
  • 166