- Pure whitespace change
- In preparation to deprecate it in favor of FormatJson / json_encode
$s = '[';
foreach ( $value as $elt ) {
if ( $s != '[' ) {
- $s .= ', ';
+ $s .= ',';
}
$s .= self::encodeJsVar( $elt );
}
$s = '{';
foreach ( (array)$value as $name => $elt ) {
if ( $s != '{' ) {
- $s .= ', ';
+ $s .= ',';
}
- $s .= '"' . self::escapeJsString( $name ) . '": ' .
+ $s .= '"' . self::escapeJsString( $name ) . '":' .
self::encodeJsVar( $elt );
}
$s .= '}';
function testEncodeJsVarArray() {
$this->assertEquals(
- '["a", 1]',
+ '["a",1]',
Xml::encodeJsVar( array( 'a', 1 ) ),
'encodeJsVar() with array'
);
$this->assertEquals(
- '{"a": "a", "b": 1}',
+ '{"a":"a","b":1}',
Xml::encodeJsVar( array( 'a' => 'a', 'b' => 1 ) ),
'encodeJsVar() with associative array'
);
function testEncodeJsVarObject() {
$this->assertEquals(
- '{"a": "a", "b": 1}',
+ '{"a":"a","b":1}',
Xml::encodeJsVar( (object)array( 'a' => 'a', 'b' => 1 ) ),
'encodeJsVar() with object'
);