How to convert an string with array form to an array?
<p>I got a string in this form</p>

<pre><code>payload = ["Text 1", "Text 2"]
</code></pre>

<p>I want to use <code>Text 2</code> as an object. How can I return it? </p>

<p><strong>UPDATE</strong>
I'm making a function which returns a <a href="https://developers.facebook.com/docs/messenger-platform/send-api-reference/receipt-template" rel="nofollow">generic template</a> Facebook API. 
The first <code>payload</code> works well, but I want to return a <code>string</code> and a <code>object</code> in the second <code>payload</code> ( result )</p>

<pre><code>button = [
            {
                "type": "postback",
                "title": "Buy item",
                "payload": "Buy this item: " + (product['id'])
            },
            {
                "type": "postback",
                "title": "Add to wishlist",
                "payload": result
            }
        ]
</code></pre>

<p>My second payload should look like this:</p>

<pre><code>payload = {
            'Order_item',
            product['title']
        }
</code></pre>

<p>Because I got this error <code>[buttons][1][payload] must be a UTF-8 encoded string</code> so I did convert it and it returns a <strong>STRING</strong> in this form <code>["Order_item", "Ledverlichting Fiets Blauw"]</code></p>

<p>Because I want that when a Facebook user clicks on a postback ( Add to wishlist ), the <code>product['title']</code> value will be save in Django database. And <code>product['title']</code> is the <code>Text 2</code> in the question above.</p>

<p>You need to split the string then trim and keep splitting/trimming to get all parts that you want to have in list</p>

<pre><code>s = 'payload = ["Text 1", "Text 2"]'
items = s.strip()[1:-1]
#if 'payload = ' is also part of string you need to split it also by '=' so it would be:
#items = s.split("=").strip()[1:-1] 
l = [item.strip()[1:-1] for item in items.split(",")]
</code></pre>

<p>then you have list of string that you can iterate, get n-th item and so on</p>

<pre><code>the_item = l[1]
return the_item
</code></pre>

python arrays django string