-2

このjsonStringをクエリに渡すことにしています

xxxxxx=createVenue&clientId=2&jsonString={"veneue":{"clientId":"b","name":"d","tagline":"f","phone":"b","address":"d","city":"f","state":"b","zip":"d","twitter":"f","license":"d","imagePath":"f","pickupLocation":"b"},"drinks":[{"type":"d","name":"f","servingTable":{"servingSize":"b","price":"d"}},{"type":"d","name":"f","servingTable":{"servingSize":"b","price":"d"}}],"spirits":[{"type":"d","name":"f","servingTable":{"servingSize":"b","price":"d"}},{"type":"d","name":"f","servingTable":{"servingSize":"b","price":"d"}}]}

しかし、php でデコードすると null が返されます。

$clientId = trim($_REQUEST['clientId']);
        $jsonString = trim($_REQUEST['jsonString']);
        $decodedJSON = json_decode($jsonString);

        return $decodedJSON;

$decodedJSON null を返します。

なにが問題ですか ?

4

2 に答える 2

1

解析する前に次のような値を出力してみてdie(trim($_REQUEST['jsonString']));ください - 文字列が壊れていることがわかります

この文字列がURLに挿入される場所に問題があるため、その場所で行う必要がありますurlencode(json_encode(...))

于 2013-10-21T17:15:47.433 に答える