We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Json convert error after upgrade from 20.3.0.47

json error occurs on any page containing an SFchart after application starts in VS or IIS,  Error does not occur after page reloads.  Happens on SfChart and SfAccumulationChart.

Rolling back to  "Syncfusion.Blazor.Charts" Version="20.3.0.47" eliminates the error.  Error occurs on V  20.3.0.52 and  20.3.0.59

<TargetFramework>net6.0</TargetFramework>


Exception Message

The JSON value could not be converted to System.String[]. Path: $[0] | LineNumber: 0 | BytePositionInLine: 2.

StackTrace

at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex) at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at Syncfusion.Blazor.Charts.SfAccumulationChart.GetCharSizeList(List`1 fontKeys) at Syncfusion.Blazor.Charts.SfAccumulationChart.SetCharSize() at Syncfusion.Blazor.Charts.SfAccumulationChart.ProcessChart() at Syncfusion.Blazor.Charts.SfAccumulationChart.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

InnerException

System.InvalidOperationException: Cannot get the value of a token type 'StartObject' as a string. at System.Text.Json.Utf8JsonReader.GetString() at System.Text.Json.Serialization.Converters.StringConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value) at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)


Exception Message

The JSON value could not be converted to System.String[]. Path: $[0] | LineNumber: 0 | BytePositionInLine: 2.

StackTrace

at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex) at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at Syncfusion.Blazor.Charts.SfChart.GetCharSizeList(List`1 fontKeys) at Syncfusion.Blazor.Charts.SfChart.SetCharSize() at Syncfusion.Blazor.Charts.SfChart.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

InnerException

System.InvalidOperationException: Cannot get the value of a token type 'StartObject' as a string. at System.Text.Json.Utf8JsonReader.GetString() at System.Text.Json.Serialization.Converters.StringConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value) at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)




5 Replies 1 reply marked as answer

DG Durga Gopalakrishnan Syncfusion Team December 2, 2022 02:24 PM UTC

Hi Justin,


We suggest you to refer the latest script reference in your application while upgrading the latest NuGet package version to overcome the reported problem. Please check with the below snippet and sample.


<head>

   <link rel='nofollow' href=https://cdn.syncfusion.com/blazor/20.3.59/styles/material.css rel="stylesheet" />

   <script src=https://cdn.syncfusion.com/blazor/syncfusion-blazor-base.min.js></script>

   <script src=https://cdn.syncfusion.com/blazor/20.3.59/syncfusion-blazor.min.js type="text/javascript"></script>     

</head>



Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/SfChart-68762175.zip


Please let us know if you have any concerns.


Regards,

Durga Gopalakrishnan.


Marked as answer

HB Hakop Balyan December 2, 2022 06:57 PM UTC

thank you Durga, this was the problem.



DG Durga Gopalakrishnan Syncfusion Team December 6, 2022 04:50 AM UTC

Hi Hakop,


Most welcome. Please get back to us if you need any further assistance. We are always happy in assisting you.


Regards,

Durga Gopalakrishnan.



AF Andrew Fong March 29, 2023 01:17 PM UTC

Hi Durga,


Your suggestion did not work for me. I am upgrading from 20.3.0.50 to 20.3.0.59. My system is a WebAssembly application and I had to revert Charts back to 20.3.0.50.


I had put the script reference in index.html as you suggested but to no avail. All other components have been upgraded to 20.3.0.59.


Any suggestions, or has it been fixed in a later version?


Thanks

Andrew




DG Durga Gopalakrishnan Syncfusion Team March 30, 2023 02:44 PM UTC

Andrew,


We have ensured your reported scenario with specified version 20.3.0.59. Chart control is rendering properly with installed NuGet package. Please check with the below screenshot and sample.


You can refer the scripts from static web assets instead of CDN reference as like below snippet.


Common NuGet : Syncfusion.Blazor


_Layout.cshtml

<head>

    <link rel='nofollow' href="_content/Syncfusion.Blazor/styles/bootstrap5.css" rel="stylesheet" />

    <script src="_content/Syncfusion.Blazor/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>

</head>


Individual NuGet : Syncfusion.Blazor.Charts


_Layout.cshtml

<head>

    <link rel='nofollow' href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />

    <script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>

</head>


UG : https://blazor.syncfusion.com/documentation/common/adding-script-references



Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Chart20.3.0.59307384124.zip


If you are still facing problem, please try to replicate an issue in above sample or share us issue reproduced sample to validate this case further from our end. Please let us know if you have any concerns.


Loader.
Up arrow icon