Skip to content

Commit

Permalink
fix deserialize dictionary value bug (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
isra-fel committed Sep 1, 2020
1 parent 01e526e commit 5bfd3a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions powershell/llcsharp/model/model-class-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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} );`));
}
Expand Down

0 comments on commit 5bfd3a1

Please sign in to comment.