Team,
I'm trying to generate a JSON string but I keep running into issues with (I guess) quotes.
Code:
<?php
// JSON data generated
$attachment = "[{
'contentType': 'application/json',
'content': {
'type': 'mytype',
'body': [{
'type': 'TextInfo',
'text': 'TEST TEXT',
'wrap': true
}]
}
}]";
// Add attachment string (JSON data) in an array
$mydata = array(
'space' => "abc",
'markdown' => "**welcome**",
'attachment' => $attachment
);
// Turn array into one big JSON string
$send_json = json_encode($data2);
What this should generate:
{
"space": "abc",
"markdown": "**welcome**",
"attachment": [{
'contentType': 'application/json',
'content': {
'type': 'mytype',
'body': [{
'type': 'TextInfo',
'text': 'TEST TEXT',
'wrap': true
}]
}
}]
}
It feels like I'm missing something (besides the required knowledge ;-).
json_encode()on it to generate the JSON String$mydata = (object)array();that should give you an object to work with in js rather than an array.