igorw/ConfigServiceProvider — pull request #14 by airdeck (2013-02-02 06:26:15+00:00)
Title: Object properties are merged when using more than one JSON file

When two configs are used (e.g. a config_base.json and then an environment-specific config file) the subsequent config file is merged with the first so that properties aren't lost.

Below is an example of loading one base config file, and then loading an environment-specific config that overrides _some_ of the properties, adds new ones that don't exist, and doesn't delete properties that aren't used in the "extended" json file. Notice that arrays, as intended, will overwrite each other as opposed to merging like object properties do.

config_base.json:
```json
{"test":{
"value1":"a",
"value2":"a",
"object1":{
"value1":"a",
"value2":"a",
"sub1":{
"value1":"a",
"value2":"a"
}
},
"array":["a1","a2"]
}}
```
config_local.json:
```json
{"test":{
"value2":"b",
"value3":"b",
"object1":{
"value2":"b",
"value3":"b",
"sub1":{
"value2":"b",
"value3":"b"
}
},
"array":["b1","b2"]
}}
```
combined result:
```json
{"test":{
"value1": "a",
"value2": "b",
"value3": "b",
"object1": {
"value1": "a",
"value2": "b",
"value3": "b",
"sub1": {
"value1": "a",
"value2": "b",
"value3": "b"
}
},
"array": ["b1","b2"]
}}
```