本文整理汇总了PHP中JSON::stringify方法的典型用法代码示例。如果您正苦于以下问题:PHP JSON::stringify方法的具体用法?PHP JSON::stringify怎么用?PHP JSON::stringify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSON
的用法示例。
在下文中一共展示了JSON::stringify方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: JSON
{
$this->innerobject = new object2();
}
}
class object2
{
var $firstattr = 'firstvalue';
var $secondattr = 'secondvalue';
}
//---- variables ---------------------------------------------------------------
$JSON = new JSON();
$object1 = new object1();
$JSON2 = new Services_JSON();
$submitted = false;
//---- logic -------------------------------------------------------------------
$origjsonstring = $JSON->stringify($object1);
$newjsonstring = $JSON2->encode($object1);
$origjson = $_REQUEST["origjson"];
if (!empty($origjson)) {
$origjsonprintr = $JSON->parse(stripslashes($origjson));
$submitted = true;
} else {
$origjsonprintr = "Not submitted";
}
$newjson = $_REQUEST["newjson"];
if (!empty($newjson)) {
$newjsonprintr = $JSON2->decode(stripslashes($newjson));
} else {
$newjsonprintr = "Not submitted";
}
//---- content -----------------------------------------------------------------
示例2: convertRequestToCurlCommand
/**
* Converts Request to Curl console command.
*
* @param Request $request
*
* @return string
*/
public static function convertRequestToCurlCommand(Request $request)
{
$message = 'curl -X' . strtoupper($request->getMethod()) . ' ';
$message .= '\'http://' . $request->getConnection()->getHost() . ':' . $request->getConnection()->getPort() . '/';
$message .= $request->getPath();
$query = $request->getQuery();
if (!empty($query)) {
$message .= '?' . http_build_query($query);
}
$message .= '\'';
$data = $request->getData();
if (!empty($data)) {
$message .= ' -d \'' . JSON::stringify($data) . '\'';
}
return $message;
}
示例3: JSON
{
return $this->name;
}
}
//---- variables ---------------------------------------------------------------
$JSON = new JSON();
$myObj = new MyObj();
//---- logic -------------------------------------------------------------------
/* initialize object */
$myObj->setId('�l' . chr(18) . "ie\nn");
$myObj->setName('objectName');
array_push($myObj->attribs, '�first');
array_push($myObj->attribs, 'second');
array_push($myObj->attribs, 3);
/* create JSON representation */
$jsonStr = $JSON->stringify($myObj);
//---- clean-up ----------------------------------------------------------------
//---- content -----------------------------------------------------------------
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JSON parser test</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="json.js"></script>
<script type="text/javascript">
JSON.arrayObj = new Array();
JSON.parse2 = function (text)
{
var p = /^\s*(([,:{}\[\]])|"(\\.|[^\x00-\x1f"\\])*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null|\/\*Array\*\/)\s*/,
token,
operator;