Questions tagged [json-serializable]

102 questions
0
votes
0 answers

Could not generate fromJson code for orders To support the type ToMany you can: Use JsonConverter

I am using objectbox for local database and also json_serializable but their is issue coming I am using two model one is CustomerModel and another is OrderModel and Creating Many to One Relation But json_serializable is not allowing to…
0
votes
1 answer

freezed package can not generate toJson code for nested object anymore

We've discovered an issue in our monorepo that prevents us from generating .g.dart files for our models. Most of the models are deeply nested and need fromJson/toJson methods to communicate with our backend. Three weeks ago we updated freezed and…
0
votes
1 answer

Dart Enums included as Null in Json even if include_if_null: false

This is a new issue I've found and was wondering if anyone else encountered it. Recently in my classes that have an enum field, when I use the toJson() method, any of the enums that are null produce a null in the map, even if they should be ignored.…
Grey
  • 331
  • 3
  • 11
0
votes
1 answer

Python Object of type Binary is not JSON serializable

I'm trying to pull data from the MongoDB port of some threads with MongoClient. However, I am getting an error when writing to the JSON file. I think there is a Binary data type in the incoming data. How do I fix this error? My code: import…
0
votes
2 answers

Using dart's json_serializable package with custom properties

Background I'm trying to use the dart json_serializable package to encode/decode a custom type I'm writing/reading with Google Cloud Firestore, and I'm having an issue with the custom type having properties that are also custom types. I'm storing a…
0
votes
1 answer

Flutter - How to use DataClass object in a model I want to serialize?

I am using Drift (Moor) v2.0.2+1 library for my local database and json_serializable v6.3.1 library to serialize my data models. Then I use build_runner v2.2.0 library to generate boilerplate code for both. I have a database table called Passenger…
rya
  • 1,417
  • 1
  • 16
  • 29
0
votes
0 answers

How to nest a class for JsonSerializable without getting a cast error when trying to create an "empty shell"

I'm trying to import/export/store accumulated data in a json file. I want all keys to show in the json file with the value null when they have not been assigned something. So I kind of need an "empty shell" at the beginning. This worked fine while I…
EN20
  • 51
  • 11
0
votes
1 answer

How to Generate Json_Serializable Dart (Flutter) on Inheritance class?

Hello i have 2 parent class Student and Room, which two of them inheritance class model StudentModel and RoomModel, i am try to generate json converter using Json_Serializable Library on Model Class, but when i try to generate with build_runner its…
Sapatekno
  • 1
  • 1
0
votes
2 answers

How to deserialize a JSON where some keys are duplicated

The json response looks like this: { "name": "A name", "international": { "name": { "en": "A name", "fr": "Un nom" } } } I tried the following code to deserialize it: import…
Cevilur
  • 11
  • 3
0
votes
0 answers

while saving YOLOv4 model TypeError: ('Not JSON Serializable:' #91

I face an error while save the YOLOv4 model when I run this command : python save_model.py --weights ./data/custom.weights --output ./checkpoints/custom-416 --input_size 416 --model yolov4 the error message: TypeError: ('Not JSON Serializable:',…
Nxxx
  • 1
0
votes
1 answer

JsonSerializable. Can't match Model to json schema

The following json is the response body of a request at Google Place Details Api. { "html_attributions": [], "result": { "address_components": [ { "long_name": "18", "short_name": "18", …
0
votes
1 answer

Flutter deserialization of inherited classes with json_serializable

I have problem trying deserialise inherited class with json_serializable package in Dart/Flutter. Here is the code example: @JsonSerializable(explicitToJson: true) class Document { String id = UniqueKey().toString(); String name=''; …
0
votes
1 answer

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1

I am trying to serialize the bellow JSON data in java [{ "clear": "0", "default": ["123","234"], "mandatory": "1", "visible": "1" }] my serializer Class looks like bellow, public class…
0
votes
1 answer

json serializable: variables declared in model class but does not exist in json

I have a problem, I have a simple model class, that has few variables, but, one of them is not necessarily present all the time. but JsonSerializable doesn't convert json to model object if that one key is not available in json data. Sample code…
user16859477
0
votes
0 answers

JsonSerializable not returning object after adding a double typed property

I generated Item model instance from json using JsonSerializable and I got this generated code. But it doesn't return an Item after I added a double typed property (price). It worked without it Item _$ItemFromJson(Map json) { …