Javascript changing code for reading modified object
<p>I have some code that's already working but I need to change the object structure and I need to modify the code so it works again.</p>

<p>Here is the working code (with the original object data):</p>

<pre><code>obj = {
    "category": [
        {
            "id": "1",
            "category": "1",
            "tags": {
                "483": "tag1",
                "484": "tag2"
            }
        },
        {
            "id": "2",
            "category": "1",
            "tags": {
                "483": "tag1",
                "484": "tag2"
            }
        },
        {
            "id": "3",
            "category": "2",
            "tags": {
                "483": "tag1",
                "484": "tag2"
            }
        },
        {
            "id": "4",
            "category": "2",
            "tags": {
                "483": "tag1",
                "484": "tag2"
            }
        },
        {
            "id": "5",
            "category": "3",
            "tags": {
                "483": "tag1",
                "484": "tag2"
            }
        },
    ]
}

var results = [ ];

for (var i = 0; i &lt; obj.category.length; i++) {

    $.each( obj.category[i].tags, function( key, value ) {
      results.push(value);
    });

}

var uniqueNames = [];
$.each(results, function(i, el){
    if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
});

console.log(uniqueNames);
</code></pre>

<p>I now need to change the object to look like this structure:</p>

<pre><code>obj = {
        "id": "1",
        "category": "1",
        "tags": {
            "483": "tag1",
            "484": "tag2"
        }
    }
</code></pre>

<p><a href="https://jsfiddle.net/myfiddles2016/qte5oa9g/2/" rel="nofollow">JSFiddle</a></p>

<p>So, basically  the category has been taken out.</p>

<p>How can i get it to work with my new object structure?</p>

<p><em>Note: The code is supposed to get all the tag names available, then remove duplicates and finally add the result to an array</em></p>