get_json ()

Gets the JSON string with the whitespace removed.

Access

public

Returns

Type

Description

string

The JSON string without extraneous whitespace.

Examples

Create a policy and get the JSON policy document.

// Instantiate S3
$s3 = new AmazonS3();

// Create a new S3 policy using an associative array
$policy = new CFPolicy($s3, array(
	'Version' => '2008-10-17',
	'Statement' => array(
		array( // Statement #1
			'Sid' => 'AddPerm',
			'Effect' => 'Allow',
			'Principal' => array(
				'AWS' => '*'
			),
			'Action' => array('s3:ReadObject'),
			'Resource' => array('arn:aws:s3:::my-bucket/*')
		)
	)
));

// Success?
var_dump($policy->get_json());
Result:
string(172) "{"Version":"2008-10-17","Statement":[{"Sid":"AddPerm","Effect":"Allow","Principal":{"AWS":"*"},"Action":["s3:ReadObject"],"Resource":["arn:aws:s3:::aws-php-sdk-test\/*"]}]}"

Related Methods

Source

Method defined in utilities/policy.class.php | Toggle source view (4 lines) | View on GitHub

public function get_json()
{
    return $this->json_policy;
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback