Skip to content

Commit 5bfd3a1

Browse files
authored
fix deserialize dictionary value bug (#684)
1 parent 01e526e commit 5bfd3a1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

powershell/llcsharp/model/model-class-json.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { popTempVar, pushTempVar } from '../schema/primitive';
3030

3131
import { ModelProperty } from './property';
3232
import { ObjectImplementation } from '../schema/object';
33+
import { NewModelInterface } from './interface';
3334

3435
export class JsonSerializableClass extends Class {
3536
private btj!: Method;
@@ -299,8 +300,9 @@ export class NewJsonSerializableClass extends Class {
299300
// wildcard style
300301
deserializeStatements.push(new Statements(`${ClientRuntime.JsonSerializable}.FromJson( json, ${ap}, ${ClientRuntime.JsonSerializable}.DeserializeDictionary(()=>${System.Collections.Generic.Dictionary(System.String, System.Object).new()}),${exclusions.value} );`));
301302

302-
} else if (vType instanceof ObjectImplementation) {
303-
deserializeStatements.push(new Statements(`${ClientRuntime.JsonSerializable}.FromJson( json, ${ap}, (j) => ${this.modelClass.fullName}.FromJson(j) ,${exclusions.value} );`));
303+
} else if (vType instanceof NewModelInterface) {
304+
// use the class of the dictionary value to deserialize values
305+
deserializeStatements.push(new Statements(`${ClientRuntime.JsonSerializable}.FromJson( json, ${ap}, (j) => ${vType.classImplementation.fullName}.FromJson(j) ,${exclusions.value} );`));
304306
} else {
305307
deserializeStatements.push(new Statements(`${ClientRuntime.JsonSerializable}.FromJson( json, ${ap}, null ,${exclusions.value} );`));
306308
}

0 commit comments

Comments
 (0)