1# Access with default value: value 2 3## Overview 4 5In many situations such as configuration files, missing values are not exceptional, but may be treated as if a default value was present. 6 7??? example 8 9 Consider the following JSON value: 10 11 ```json 12 { 13 "logOutput": "result.log", 14 "append": true 15 } 16 ``` 17 18 Assume the value is parsed to a `json` variable `j`. 19 20 | expression | value | 21 | ---------- | ----- | 22 | `#!cpp j` | `#!json {"logOutput": "result.log", "append": true}` | 23 | `#!cpp j.value("logOutput", "logfile.log")` | `#!json "result.log"` | 24 | `#!cpp j.value("append", true)` | `#!json true` | 25 | `#!cpp j.value("append", false)` | `#!json true` | 26 | `#!cpp j.value("logLevel", "verbose")` | `#!json "verbose"` | 27 28## Note 29 30!!! failure "Exceptions" 31 32 - `value` can only be used with objects. For other types, a [`basic_json::type_error`](../../home/exceptions.md#jsonexceptiontype_error306) is thrown. 33