<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: JsonDeserialization error in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/JsonDeserialization-error/m-p/2106117#M19003</link>
    <description>&lt;P&gt;Thank you for the explanation&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2023 06:02:59 GMT</pubDate>
    <dc:creator>andreas-hellquist-stratsys</dc:creator>
    <dc:date>2023-08-16T06:02:59Z</dc:date>
    <item>
      <title>JsonDeserialization error</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/JsonDeserialization-error/m-p/2090690#M18766</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get below errror when trying to deserialize table data.&lt;/P&gt;
&lt;P&gt;Property "qDimensionInfo" accessed as System.Collections.Generic.IEnumerable`1[[Qlik.Sense.Client.Visualizations.HyperCubeDimensionq, Qlik.Sense.Client, Version=16.4.0.0]] previously interpreted as System.Collections.Generic.List`1[[Qlik.Engine.NxDimensionInfo, Qlik.Engine, Version=16.4.0.0]]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Our partner upgraded to a new QlikSense version a week or so ago to May SR1 (don’t know if that is correctly notation) but no major release of .NET SDK lately so I guess I am missing something else.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2023 11:49:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/JsonDeserialization-error/m-p/2090690#M18766</guid>
      <dc:creator>andreas-hellquist-stratsys</dc:creator>
      <dc:date>2023-07-05T11:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: JsonDeserialization error</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/JsonDeserialization-error/m-p/2090923#M18772</link>
      <description>&lt;P&gt;This type of errors occur when a property of a class derived from the abstract structure class is deserialized with two different types. In this case, the dimensions have been deserialized as a list of "NxDimensionInfo", but the hypercube is then accessed through a client class which tries to interpret them as the client extension class "HyperCubeDimensionq". It tries to do an up-cast of the type, which fails.&lt;/P&gt;
&lt;P&gt;Here is an example that illustrates how to end up in such a situation:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;var o = app.GetObject&amp;lt;Table&amp;gt;(objId);
var tableCube = o.Properties.HyperCubeDef;        // Get table cube
var engineCube = tableCube.As&amp;lt;HyperCubeDef&amp;gt;();    // Interpret as engine cube
Console.WriteLine(engineCube.Dimensions.Count()); // Count engine cubes
Console.WriteLine(tableCube.Dimensions.Count());  // Count table cubes&lt;/LI-CODE&gt;
&lt;P&gt;During the first call to "Dimensions", the access is performed through the variable "engineCube". In this case, the type of the property "Dimensions" is "IEnumerable&amp;lt;NxDimension&amp;gt;". The data must be deserialized to an explicit type, not just an interface, and by default, the type "List" is used. So the dimensions are in fact deserialized to "List&amp;lt;NxDimension&amp;gt;".&lt;/P&gt;
&lt;P&gt;Then during the second call, the dimensions are accessed through the variable "tableCube" for which the property "Dimensions" has the type "IEnumerable&amp;lt;TableHyperCubeDimensionDef&amp;gt;". But that property has now already been deserialized as "List&amp;lt;NxDimension&amp;gt;" which is incompatible with this new type, so the error is thrown. Note that it all works fine if you switch the order of the two counts. It's fine to down-cast a "TableHyperCubeDimensionDef" to "NxDimension", but you can't up-cast an "NxDimension" to a "TableHyperCubeDimensionDef".&lt;/P&gt;
&lt;P&gt;This an unfortunate limitation with the abstract structure concept, but there is a pretty simple workaround. Simply do a clone of the object, that way you will get a copy that you can deserialize in a new way. In the above example, one could for instance use "CloneAs" instead of just "As" when setting the "engineCube" variable like this:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;var o = app.GetObject&amp;lt;Table&amp;gt;(objId);                 
var tableCube = o.Properties.HyperCubeDef;          // Get table cube
var engineCube = tableCube.CloneAs&amp;lt;HyperCubeDef&amp;gt;(); // Clone as engine cube
Console.WriteLine(engineCube.Dimensions.Count());   // Count engine cubes
Console.WriteLine(tableCube.Dimensions.Count());    // Count table cubes&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;More about the concept of abstract structure in the .NET SDK can be found here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/February2023/Subsystems/NetSDKAPI/Content/Sense_NetSDKAPI/HowTos/Net-Sdk-How-To-Abstarct-Structure.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense-developer/February2023/Subsystems/NetSDKAPI/Content/Sense_NetSDKAPI/HowTos/Net-Sdk-How-To-Abstarct-Structure.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 07:16:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/JsonDeserialization-error/m-p/2090923#M18772</guid>
      <dc:creator>Øystein_Kolsrud</dc:creator>
      <dc:date>2023-07-06T07:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: JsonDeserialization error</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/JsonDeserialization-error/m-p/2106117#M19003</link>
      <description>&lt;P&gt;Thank you for the explanation&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 06:02:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/JsonDeserialization-error/m-p/2106117#M19003</guid>
      <dc:creator>andreas-hellquist-stratsys</dc:creator>
      <dc:date>2023-08-16T06:02:59Z</dc:date>
    </item>
  </channel>
</rss>

