Skip to content

Failing to deserialize due to reference IDs on serialized UnityEngine.Color #57

@Din-Wan

Description

@Din-Wan

Hi! I hope I'm posting this in the right place...
I am currently having a teeny problem with deserializing some JSON in my project. Originally, my project was using JSON .NET for Unity plugin by ParentElement, and so I have a lot of files which contain JSON that was created using their serializer. They were created with the following settings:
var settings = new JsonSerializerSettings() { PreserveReferencesHandling = PreserveReferencesHandling.Objects };

The object I serialized contained UnityEngine.Color and the resulting JSON contained $id metadata for the Colors. However, when I used your serializer with the converter and the same ReferenceHandling settings, $id tags are not generated for the Colors.
The problem I am having is when I try to deserialize the existing JSON in my project, I get the following error:

Newtonsoft.Json.JsonSerializationException : Unexpected token while deserializing object: PropertyName. Path 'Path.To.Property.After.Color'

If it helps, here is the class containing the Color:

[JsonObject(MemberSerialization = MemberSerialization.Fields)]
public class Style
{
  ...
  private Color32 color;
  public Color Color { get; set; }
  ...
}

I was wondering you might know what's going wrong and of any way of dealing with this issue. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions