astaxie/beego — pull request #644 by chrisport (2014-06-11 08:52:09+00:00)
Title: config: fix error when json config starts with an array

[Bugfix] In case a json config has an array as root (which is valid json) the following error happened while trying to Unmarshal in the Parse-method:
json: cannot unmarshal array into Go value of type map[string]interface {}=== RUN TestJson

I added a few lines to prevent this error. In case Unmarshal gives back an err, it tries to Unmarshal as [] interface{} instead of map[string] interface{}.
- If this fails too, err from the **first** Unmarshal attempt is returned.
- If it is successful (= root is an array), the array is stored in the value "rootArray" in order to not violate other methods. The array can be accessed by calling DIY("rootArray") on the resulting config (to be added to config).

A testcase is added using a json-file starting with an array as root