Voice deserialization issue #95
-
Bug ReportOverviewI'm getting a private ElevenLabsClient _client = new ElevenLabsClient(ApiKey);
public async Task<IEnumerable<Voice>> GetAllVoicesAsync(CancellationToken cancellationToken)
{
return await _client.VoicesEndpoint.GetAllVoicesAsync(cancellationToken);
} I can't reproduce the error when I create a new project, it only occurs in an existing project. I understand why it occurs, but I don't understand why it doesn't occur in a new project (maybe there is a difference in project configurations). This is happening because the [SerializeField]
private string name;
[Preserve]
[JsonProperty("name")]
public string Name
{
get => name;
private set => name = value;
} The SolutionRename the Private Fields in the
[SerializeField]
private string _name;
[Preserve]
[JsonProperty("name")]
public string Name
{
get => _name;
private set => _name = value;
}
[Range(0f, 1f)]
[SerializeField]
private float _stability = 0.75f;
[Preserve]
[JsonProperty("stability", DefaultValueHandling = DefaultValueHandling.Include)]
public float Stability
{
get => _stability;
set => _stability = value;
}
...
[Range(0f, 1f)]
[SerializeField]
private float _style = 0.45f;
[Preserve]
[JsonProperty("style", DefaultValueHandling = DefaultValueHandling.Include)]
public float Style
{
get => _style;
set => _style = value;
} Additional contextUsing the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This shouldn't typically be a problem and since this package is well established, I will most likely not add the superfluous I have seen issues like this before in other project that somehow manage to silently rewrite the serialization options, One that comes to mind is https://github.com/applejag/Newtonsoft.Json-for-Unity.Converters You'll need to disable the option to automatically serialize/deserialize private fields, or fix the project in question to properly use the NewtonSoft json instead of this package. I dislike this package bc it rewrites the serialization options specifically set for the package in the Client. |
Beta Was this translation helpful? Give feedback.
-
Disabling |
Beta Was this translation helpful? Give feedback.
This shouldn't typically be a problem and since this package is well established, I will most likely not add the superfluous
_
prefix.Even if I did rename the
FormerlySerializedAs("name")
attribute would still likely cause serialization errors similar to what you're seeing.I have seen issues like this before in other project that somehow manage to silently rewrite the serialization options,
do you have a custom serializer or something that changes the default Json serializer in your project?
One that comes to mind is https://github.com/applejag/Newtonsoft.Json-for-Unity.Converters
You'll need to disable the option to automatically serialize/deserialize private fields, or fix the project…