Inicializando objeto JSON en TypeScript
Soy nuevo en TypeScript y estoy atascado en trabajar con JSON. Necesito crear un objeto JSON simple y sigo fallando al hacerlo. Aquí están mis primeros intentos:
output: JSON; //declaration
this.output = {
"col1":{"Attribute1": "value1", "Attribute2": "value2", "Attribute3": "value3"},
"col2":{"Attribute1": "value4", "Attribute2": "value5", "Attribute3": "value6"},
"col3":{"Attribute1": "value7", "Attribute2": "value8", "Attribute3": "value9"}
}
Esto no funciona. Supongo que debería trabajar con la función JSON.stringify. Aquí está mi intento:
obj: any; //new object declaration
this.obj = {
"col1":{"Attribute1": "value1", "Attribute2": "value2", "Attribute3": "value3"},
"col2":{"Attribute1": "value4", "Attribute2": "value5", "Attribute3": "value6"},
"col3":{"Attribute1": "value7", "Attribute2": "value8", "Attribute3": "value9"}
}
this.output.stringify(this.obj);
Pero esto todavía invoca TypeError. Entonces, para resumir mi pregunta: ¿cómo crear e inicializar correctamente el objeto JSON en TypeScript?