Eğer PHP veri var sonra, json_encode
a> işlevini kullanabilirsiniz; PHP 5.2 beri PHP ile birlikte oluyor
Sizin durumunuzda JSON dize temsil eder:
- 2 elemanları içeren bir liste
- her biri 2 özellikleri / değerleri içeren bir nesne olmaktan
PHP, bu temsil yapıyı da oluşturmak istiyoruz:
$data = array(
(object)array(
'oV' => 'myfirstvalue',
'oT' => 'myfirsttext',
),
(object)array(
'oV' => 'mysecondvalue',
'oT' => 'mysecondtext',
),
);
var_dump($data);
var_dump
alır:
array
0 =>
object(stdClass)[1]
public 'oV' => string 'myfirstvalue' (length=12)
public 'oT' => string 'myfirsttext' (length=11)
1 =>
object(stdClass)[2]
public 'oV' => string 'mysecondvalue' (length=13)
public 'oT' => string 'mysecondtext' (length=12)
Ve, JSON için kodlayan:
$json = json_encode($data);
echo $json;
Alacağınız:
[{"oV":"myfirstvalue","oT":"myfirsttext"},{"oV":"mysecondvalue","oT":"mysecondtext"}]
BTW : Frolm what I remember, I'd say your JSON string is not valid-JSON data : there should be double-quotes arround the string, including the names of the objects properties
See http://www.json.org/ dilbilgisi için. Em>
Hope this helps :-)