I have created a new class with the following properties:
'''
import { Deserializable } from '../deserializable';
export class Outdoor implements Deserializable {
ActualTemp: number;
TargetTemp: number;
Day: number;
deserialize(input: any): this {
// Assign input to our object
if(input){
Object.assign(this, input);
}
return this;
}
toJSON() {
return Object.assign({}, this);
}
}
'''
The toJSON function is used to convert the class data into a JSON String by calling:
'''
const resource = JSON.stringify(this.appEngineMsg.Outdoor.toJSON());
'''
{"ActualTemp":60, "TargetTemp":55,"Day":23}
If I modify the values of this.appEngineMsg.Outdoor.TargetTemp or this.appEngineMsg.Outdoor.ActualTemp, I want to receive the following JSON strings:
{"Outdoor":{"TargetTemp":100}}
{"Outdoor":{"ActualTemp":100}}
What would be the most efficient way to achieve this?