Questions tagged [json-serialization]

302 questions
6
votes
2 answers

Dart JsonSerializable with abstract class

I'm trying to generate my json helper functions for an object, that contains a list with the type of an abstract class, like this: import 'package:json_annotation/json_annotation.dart'; import 'exercise-variations.a.dart'; part…
Jonas
  • 7,089
  • 15
  • 49
  • 110
6
votes
3 answers

Flutter/Dart JSON and serialization of an existing library class

I have a class: import 'package:google_maps_flutter/google_maps_flutter.dart'; class Place { Place({ this.address, this.coordinates, }); final String address; final LatLng coordinates; } LatLng is a class of google_maps_flutter.…
Marco
  • 593
  • 8
  • 23
6
votes
1 answer

json_serializable plugin doesn't support 'File' type?

I'm using json_serializable plugin, but it doesn't seem to work with File for images. 'myclass.g.dart' is not generated. I don't have any troubles for the other types. (https://pub.dev/packages/json_serializable/versions/0.5.4#-readme-tab-) This is…
Herinn
  • 189
  • 2
  • 8
6
votes
3 answers

AspNet Core - input/output JSON serialization settings at Controller Level

My application requires the (almost default) JSON serialization settings: services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddJsonOptions(options => { …
ExternalUse
  • 2,053
  • 2
  • 25
  • 37
6
votes
2 answers

Generating dart file with json_serializable package

According to the json_serializable package installing instructions, you should add the following dependency: dependencies: json_serializable: ^2.0.3 This is my code: import 'package:json_annotation/json_annotation.dart'; part…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
6
votes
1 answer

Json serialization of Python Properties class

I have a Properties class : from child_props import ChildProps class ParentProps(object): """Contains all the attributes for CreateOrderRequest""" def __init__(self): self.__prop1 = None self.__child_props =…
Ankur
  • 71
  • 1
  • 4
6
votes
1 answer

What is equivalent code settings for @JSonIgnore annotation?

I'm new to Java and Jackson and a lot of other technologies which I try to use, so I'd appreciate a detailed answer. Is there a way to prevent one or more fields from being serialized using Jackson into a JSON String_like format, but without using…
niceman
  • 161
  • 1
  • 3
  • 11
5
votes
2 answers

How do I serialize object properties to lower case using System.Text.Json?

I have an ASP.NET 5 MVC Core application controller with the below code inside: using System.Text.Json; public async Task EstoAPICall() { ... EstoOst estoOst; var json = JsonSerializer.Serialize(estoOst); StringContent…
Andrus
  • 26,339
  • 60
  • 204
  • 378
5
votes
1 answer

Angular serialize Date with specific format in POST request

I am new to Angular and I have several doubts about what is the best way to serialize a Date property of an object added to a POST request. Given the sample class export class MyClass{ public dateProperty: Date; } I have the following code in…
user2297037
  • 1,167
  • 2
  • 14
  • 34
4
votes
2 answers

How to change property names when serializing with dart json_serializable?

Here is a json file person.json { "first_name": "John", "last_name": "Doe" } Here is the Person class import 'package:json_annotation/json_annotation.dart'; part 'person.g.dart'; @JsonSerializable() class Person { /// The generated code…
s-hunter
  • 24,172
  • 16
  • 88
  • 130
4
votes
2 answers

Error converting string to type 'System.Text.Json.JsonElement

I have an class which consist in which i have some problems filling a jsonElement from a json file as such { "entities": [ { "name": "DateTimeENT1", "description": "This a example", "uil": { …
howdoI
  • 51
  • 1
  • 1
  • 5
4
votes
4 answers

flutter json_serializable tojson does not work properly

Im looking into the Order class example and found that the Item class is not converted to Map. class Order { int count; int itemNumber; bool isRushed; Item item; Map toJson() => _$OrderToJson(this); } The generated .g…
Panda World
  • 1,704
  • 1
  • 20
  • 28
4
votes
1 answer

HttpClient postasync with custom header and application/json for body C#

Hello I want to run push app center from its api. But I don't know how to make the proper format. I want to postasync from this api: https://appcenter.ms/api/v0.1/apps/KacangIjo/ShopDiaryApp/push/notifications What it needs for Headers…
Yeremia Danang
  • 139
  • 1
  • 2
  • 12
4
votes
1 answer

How to format NodaTime date string globally in ASP.NET Core 2.1?

Currently, I am trying to use the JsonFormatters for serializing a string in ISO 8601 spec. format in my startup config, but could not get it to work. My Startup Config is as follows: services.AddMvcCore( (options) => { options.SslPort =…
JSON
  • 1,583
  • 4
  • 31
  • 63
3
votes
1 answer

Kotlinx-serialization: Serialize raw string without quotes

What I try to achieve Using Jackson for serialization, there is the @JsonRawValue annotation to achieve that a string value is serialized without quotes. For instance, with the following code data class SomeData { @JsonRawValue value:…
1
2
3
20 21