Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> PHP

Tạo object JSON lồng nhau trong PHP


Cấu trúc JSON có thể tạo bằng mã dưới:

$json = json_encode(array( 
    "client" => array( 
        "build" => "1.0", 
        "name" => "xxxx", 
        "version" => "1.0" 
    ), 
    "protocolVersion" => 4, 
    "data" => array( 
        "distributorId" => "xxxx", 
        "distributorPin" => "xxxx", 
        "locale" => "en-US" 
    ) 
));