Permalink
Browse files

BUGFIX #5862 JSON output of JSONDataFormatter now uses quotes for key…

…s to be safer (from r108409)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112729 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 066bf90 commit 3ddd5647a16b6f285bdbcb9214424ed03929123d @sminnee sminnee committed Oct 18, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 api/JSONDataFormatter.php
@@ -63,7 +63,7 @@ public function convertDataObject(DataObjectInterface $obj, $fields = null, $rel
} else {
$href = Director::absoluteURL(self::$api_base . "$className/$id/$relName");
}
- $jsonParts[] = "$relName : { \"className\" : \"$relClass\", \"href\" : \"$href.json\", \"id\" : \"{$obj->$fieldName}\" }";
+ $jsonParts[] = "\"$relName\" : { \"className\" : \"$relClass\", \"href\" : \"$href.json\", \"id\" : \"{$obj->$fieldName}\" }";
}
foreach($obj->has_many() as $relName => $relClass) {
@@ -80,7 +80,7 @@ public function convertDataObject(DataObjectInterface $obj, $fields = null, $rel
$href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID");
$jsonInnerParts[] = "{ \"className\" : \"$relClass\", \"href\" : \"$href.json\", \"id\" : \"{$obj->$fieldName}\" }";
}
- $jsonParts[] = "$relName : [\n " . implode(",\n ", $jsonInnerParts) . " \n ]";
+ $jsonParts[] = "\"$relName\" : [\n " . implode(",\n ", $jsonInnerParts) . " \n ]";
}
foreach($obj->many_many() as $relName => $relClass) {
@@ -97,7 +97,7 @@ public function convertDataObject(DataObjectInterface $obj, $fields = null, $rel
$href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID");
$jsonInnerParts[] = " { \"className\" : \"$relClass\", \"href\" : \"$href.json\", \"id\" : \"{$obj->$fieldName}\" }";
}
- $jsonParts[] = "$relName : [\n " . implode(",\n ", $jsonInnerParts) . "\n ]";
+ $jsonParts[] = "\"$relName\" : [\n " . implode(",\n ", $jsonInnerParts) . "\n ]";
}
}

0 comments on commit 3ddd564

Please sign in to comment.