{
param1: "1",
param2: "string",
param3: "false"
}
export class PageParams {
param1: number;
param2: string;
param3: boolean;
}
const obj = {
param1: "1",
param2: "string",
param3: "false"
};
function convertType(prop) {
try {
return JSON.parse(prop);
} catch (e) {
if (e.name === 'SyntaxError') {
return prop;
}
throw e;
}
}
Object.entries(obj).forEach(([key, value]) => {
obj[key] = convertType(value);
});
console.log(obj); // {param1: 1, param2: "string", param3: false}