1 # <small>nlohmann::basic_json::</small>get_ref
4 template<typename ReferenceType>
5 ReferenceType get_ref();
7 template<typename ReferenceType>
8 const ReferenceType get_ref() const;
11 Implicit reference access to the internally stored JSON value. No copies are made.
13 ## Template parameters
16 : reference type; must be a reference to [`array_t`](array_t.md), [`object_t`](object_t.md),
17 [`string_t`](string_t.md), [`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or
18 [`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md).
19 Enforced by static assertion.
23 reference to the internally stored JSON value if the requested reference type fits to the JSON value; throws
24 [`type_error.303`](../../home/exceptions.md#jsonexceptiontype_error303) otherwise
28 Strong exception safety: if an exception occurs, the original value stays intact.
32 Throws [`type_error.303`](../../home/exceptions.md#jsonexceptiontype_error303) if the requested reference type does not
33 match the stored JSON value type; example: `"incompatible ReferenceType for get_ref, actual type is binary"`.
43 Writing data to the referee of the result yields an undefined state.
49 The example shows several calls to `get_ref()`.
52 --8<-- "examples/get_ref.cpp"
58 --8<-- "examples/get_ref.output"
63 - Added in version 1.1.0.
64 - Extended to binary types in version 3.8.0.