From 3ddd5647a16b6f285bdbcb9214424ed03929123d Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 18 Oct 2010 22:55:06 +0000 Subject: [PATCH] BUGFIX #5862 JSON output of JSONDataFormatter now uses quotes for keys to be safer (from r108409) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112729 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- api/JSONDataFormatter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/JSONDataFormatter.php b/api/JSONDataFormatter.php index 815e141eb..2ce7476ca 100644 --- a/api/JSONDataFormatter.php +++ b/api/JSONDataFormatter.php @@ -63,7 +63,7 @@ class JSONDataFormatter extends DataFormatter { } 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 @@ class JSONDataFormatter extends DataFormatter { $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 @@ class JSONDataFormatter extends DataFormatter { $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 ]"; } }