[SalesForce] How to set a default value for an attribute of type Object

How do I set a default value for an attribute with type Object? In the example below, the default value for the country attribute should be an object with two properties: name and capital. At runtime, however, it defaults to the string "{'name':'France','capital':'Paris'}" and not an object.

<aura:attribute name="country" type="Object" default="{'name':'France','capital':'Paris'}" />

My work-around for now is to set the value in the init handler, but I'd still like to know what I'm doing wrong.

Best Answer

Well using type="Map" works fine, and it returns object as expected.

<aura:attribute name="country" type="Map" default="{'name':'France','capital':'Paris'}" />

Here's the link to the section in the doc where attributes of collection type is discussed.