Skip to content
This repository
Browse code

MINOR Add notes on upgrading for Convert::json2array() changes

  • Loading branch information...
commit c52f75e3194fd309e6ac05ed957e3da8e8f44ab4 1 parent dbc4be3
Sean Harvey authored March 31, 2012

Showing 1 changed file with 32 additions and 0 deletions. Show diff stats Hide diff stats

  1. 32  docs/en/changelogs/3.0.0.md
32  docs/en/changelogs/3.0.0.md
Source Rendered
@@ -113,6 +113,38 @@ As with any SilverStripe upgrade, we recommend database backups before calling `
113 113
 See [mysql.com](http://dev.mysql.com/doc/refman/5.5/en/converting-tables-to-innodb.html) for details on the conversion.
114 114
 Note: MySQL has made InnoDB the default engine in its [5.5 release](http://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html).
115 115
 
  116
+### Convert::json2array() changes ###
  117
+
  118
+Convert JSON functions have been changed to use built-in json PHP functions `json_decode()` and `json_encode()`
  119
+
  120
+Because `json_decode()` will convert nested JSON structures to arrays as well, this has changed the way it worked,
  121
+as before nested structures would be converted to an object instead.
  122
+
  123
+So, given the following JSON input to `Convert::json2array()`:
  124
+
  125
+	{"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}}
  126
+
  127
+Here's the output from SilverStripe 2.4, with nested JSON as objects:
  128
+
  129
+	array(
  130
+		'Joe' => 'Bloggs'
  131
+		'Tom' => 'Jones',
  132
+		'My' => stdObject(
  133
+			Complicated => 'Structure' // property on object
  134
+		)
  135
+	)
  136
+
  137
+Now in SilverStripe 3.x, nested structures are arrays:
  138
+
  139
+	array(
  140
+		'Joe' => 'Bloggs',
  141
+		'Tom' => 'Jones',
  142
+		'My' => array(
  143
+			'Complicated' => 'Structure' // key value on nested array
  144
+		)
  145
+	)
  146
+
  147
+
116 148
 ### GridField: Replacement for TableListField and ComplexTableField ###
117 149
 
118 150
 We have a new component for managing lists of objects: The `[GridField](/topics/grid-field)`.

0 notes on commit c52f75e

Please sign in to comment.
Something went wrong with that request. Please try again.