From 2f3e05ab5035238d3ad080ff30e819e5a0fd53a9 Mon Sep 17 00:00:00 2001 From: Yeming Liu Date: Tue, 1 Sep 2020 13:18:06 +0800 Subject: [PATCH] fix deserialize dictionary value bug --- powershell/llcsharp/model/model-class-json.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/powershell/llcsharp/model/model-class-json.ts b/powershell/llcsharp/model/model-class-json.ts index 08496a9350c..5af56bcfe27 100644 --- a/powershell/llcsharp/model/model-class-json.ts +++ b/powershell/llcsharp/model/model-class-json.ts @@ -30,6 +30,7 @@ import { popTempVar, pushTempVar } from '../schema/primitive'; import { ModelProperty } from './property'; import { ObjectImplementation } from '../schema/object'; +import { NewModelInterface } from './interface'; export class JsonSerializableClass extends Class { private btj!: Method; @@ -299,8 +300,9 @@ export class NewJsonSerializableClass extends Class { // wildcard style deserializeStatements.push(new Statements(`${ClientRuntime.JsonSerializable}.FromJson( json, ${ap}, ${ClientRuntime.JsonSerializable}.DeserializeDictionary(()=>${System.Collections.Generic.Dictionary(System.String, System.Object).new()}),${exclusions.value} );`)); - } else if (vType instanceof ObjectImplementation) { - deserializeStatements.push(new Statements(`${ClientRuntime.JsonSerializable}.FromJson( json, ${ap}, (j) => ${this.modelClass.fullName}.FromJson(j) ,${exclusions.value} );`)); + } else if (vType instanceof NewModelInterface) { + // use the class of the dictionary value to deserialize values + deserializeStatements.push(new Statements(`${ClientRuntime.JsonSerializable}.FromJson( json, ${ap}, (j) => ${vType.classImplementation.fullName}.FromJson(j) ,${exclusions.value} );`)); } else { deserializeStatements.push(new Statements(`${ClientRuntime.JsonSerializable}.FromJson( json, ${ap}, null ,${exclusions.value} );`)); }