restructure string in javascript
<p>I have this string in which i need to re-structure using JavaScript.</p>

<blockquote>
  <p>Label=11121212&amp;TopicArn=test&amp;AWSAccountId.member.1=YYYYYYY&amp;ActionName.member.1=createTopic&amp;Action=AddPermission&amp;Version=2010-03-31&amp;<strong>AWSAccessKeyId</strong>=XXXXXXXXX&amp;SignatureVersion=2&amp;SignatureMethod=HmacSHA1&amp;Timestamp=2012-05-02T16%3A06%3A09.000Z&amp;Signature=C3uIh%2Bz%2Fik</p>
</blockquote>

<p>For this example, <code>AWSAccessKeyId</code> should be the first part of the string and <code>label</code> should be 2nd last. There are others as well, similar to this.</p>

<p>Expected output --AWSAccessKeyId=XXXXXXXXX&amp;AWSAccountId.member.1=YYYYYYYYY&amp;Action=AddPermission&amp;ActionName.member.1=Publish&amp;Label=ios-sns-permission-label&amp;Signature=dEaNL0ibP5c7xyl4qXDPFPADW0meoUX9caKyUIx1wkk%3D&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2012-05-02T00%3A51%3A23.965Z&amp;TopicArn=arn%3Aaws%3Asns%3Aus-east-1%3A335750469596%3AiOSGoesWooooo-1335919882&amp;Version=2010-03-31</p>

<p>Code that creates this incorrect string</p>

<pre><code>exports.generatePayload = function(params, accessKeyId, secretKey, endpoint) {
    var host = endpoint.replace(/.*:\/\//, "");
    var payload = null;

    var signer = new AWSV2Signer(accessKeyId, secretKey);
    params = signer.sign(params, new Date(), {
        "verb" : "POST",
        "host" : host,
        "uriPath" : "/"
    });

    var encodedParams = [];
    for(var key in params) {
        if(params[key] !== null) {
            encodedParams.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
        } else {
            encodedParams.push(encodeURIComponent(key));
        }
    }
    payload = encodedParams.join("&amp;");
    return payload;
}
</code></pre>

<p>I tried putting this in an array and restructure it but it didn't work for me.</p>

<p>Please advice how this can be done easily using JavaScript</p>
