I am getting value in JSON format in a controller function and want to set it to attribute in it's associated component.

controller function

userFeedItem: function(component, event, helper) {
    var userFeed = component.get("c.getFeedData");
    var groupID = component.get("v.groupattid");
    console.log("GroupID: " + groupID);
    userFeed.setParams({"groupId" : groupID});
    var state = response.getState();
          var jsontext = JSON.stringify(response.getReturnValue(),null,4);
         // var jstext = JSON.parse(jsontext);
           //console.log("USERS_BODY:3 " + JSON.stringify(response.getReturnValue(), null, 4));
    //console.log("USERS_BODY:4 " + jstext);            
        } else {
            console.log('Problem getting feed, response state: ' + state);


<aura:component controller ="ChatterFeedController">
     <aura:attribute name = "groupatt" type="Object" /> 
     <aura:handler name="init" action="{!c.userFeedItem}" value="{!this}"/> 

     <div class ="slds">
     <!--Page Header-->
     <div class="slds-page-header">
        <div class="slds-grid">
        <span class="big">THOR Announcement</span>
    <section class="slds-card__body">
    <div id = "List" class="row">           
       <aura:iteration items="{!v.groupatt}" var="att">
            <span class="slds-truncate">{{display a value from the JSON}}

  • 2
    Please take a moment to visit the help center, scroll through the tour, and read How to Ask. As written, your post does not contain a question. What is the expected versus observed behavior? Do you have any error messages? Have you written any code which you can include? Please edit your post to be more detailed.
    – Adrian Larson
    Commented Apr 10, 2017 at 21:09

1 Answer 1


Since you have defined an Object attribute you need to set an object to it from your controller.

Depending on your return value from your Apex controller, you could possibly directly set the value:


Or if it's a JSON string coming back from the controller, Parse that instead:


Note, I'd probably add a bit more error checking than I have here, but this is just for example purposes.

Do not JSON.stringify() anything. You do not want a string.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .