Skip to content

Commit

Permalink
BUGFIX #5862 JSON output of JSONDataFormatter now uses quotes for key…
Browse files Browse the repository at this point in the history
…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
Sam Minnee committed Oct 18, 2010
1 parent 066bf90 commit 3ddd564
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/JSONDataFormatter.php
Expand Up @@ -63,7 +63,7 @@ public function convertDataObject(DataObjectInterface $obj, $fields = null, $rel
} else { } else {
$href = Director::absoluteURL(self::$api_base . "$className/$id/$relName"); $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) { foreach($obj->has_many() as $relName => $relClass) {
Expand All @@ -80,7 +80,7 @@ public function convertDataObject(DataObjectInterface $obj, $fields = null, $rel
$href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID"); $href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID");
$jsonInnerParts[] = "{ \"className\" : \"$relClass\", \"href\" : \"$href.json\", \"id\" : \"{$obj->$fieldName}\" }"; $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) { foreach($obj->many_many() as $relName => $relClass) {
Expand All @@ -97,7 +97,7 @@ public function convertDataObject(DataObjectInterface $obj, $fields = null, $rel
$href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID"); $href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID");
$jsonInnerParts[] = " { \"className\" : \"$relClass\", \"href\" : \"$href.json\", \"id\" : \"{$obj->$fieldName}\" }"; $jsonInnerParts[] = " { \"className\" : \"$relClass\", \"href\" : \"$href.json\", \"id\" : \"{$obj->$fieldName}\" }";
} }
$jsonParts[] = "$relName : [\n " . implode(",\n ", $jsonInnerParts) . "\n ]"; $jsonParts[] = "\"$relName\" : [\n " . implode(",\n ", $jsonInnerParts) . "\n ]";
} }
} }


Expand Down

0 comments on commit 3ddd564

Please sign in to comment.