---
title: llarp::rpc::json_binary_proxy

---

# llarp::rpc::json_binary_proxy





## Public Types

|                | Name           |
| -------------- | -------------- |
| enum class| **[fmt](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#enum-fmt)** { bt, hex, base64} |

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-json-binary-proxy)**(nlohmann::json & elem, fmt format) |
| | **[json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-json-binary-proxy)**() =delete |
| | **[json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-json-binary-proxy)**(const [json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) & ) =default |
| | **[json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-json-binary-proxy)**([json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) && ) =default |
| nlohmann::json & | **[operator*](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-operator*)**()<br>Dereferencing a proxy element accesses the underlying nlohmann::json.  |
| nlohmann::json * | **[operator->](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-operator->)**() |
| template <typename T \> <br>[json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) | **[operator[]](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-operator[])**(T && key)<br>Descends into the json object, returning a new binary value proxy around the child element.  |
| [json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) | **[front](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-front)**()<br>Returns a binary value proxy around the first/last element (requires an underlying list)  |
| [json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) | **[back](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-back)**() |
| nlohmann::json & | **[operator=](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-operator=)**(std::string_view binary_data)<br>Assigns binary data from a string_view/string/etc.  |
| template <typename Char ,std::enable_if_t< sizeof(Char)==1 &&!std::is_same_v< Char, char >, int >  =0\> <br>nlohmann::json & | **[operator=](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-operator=)**(std::basic_string_view< Char > binary_data)<br>Assigns binary data from a string_view over a 1-byte, non-char type (e.g.  |
| template <typename T ,std::enable_if_t< json_is_binary< T >, int >  =0\> <br>nlohmann::json & | **[operator=](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-operator=)**(const T & val)<br>Takes a trivial, no-padding data structure (e.g.  |
| template <typename T ,std::enable_if_t< json_is_binary_container< T >, int >  =0\> <br>nlohmann::json & | **[operator=](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-operator=)**(const T & vals)<br>Takes a vector of some json_binary_proxy-assignable type and builds an array by assigning each one into a new array of binary values.  |
| template <typename... Args\> <br>[json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) | **[emplace_back](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-emplace-back)**(Args &&... args)<br>Emplaces a new nlohman::json to the end of an underlying list and returns a [json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) wrapping it.  |
| template <typename T \> <br>void | **[push_back](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#function-push-back)**(T && val)<br>Adds an element to an underlying list, then copies or moves the given argument onto it via [json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) assignment.  |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| nlohmann::json & | **[e](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#variable-e)**  |
| enum llarp::rpc::json_binary_proxy::fmt | **[format](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md#variable-format)**  |

## Public Types Documentation

### enum fmt

| Enumerator | Value | Description |
| ---------- | ----- | ----------- |
| bt | |   |
| hex | |   |
| base64 | |   |




## Public Functions Documentation

### function json_binary_proxy

```cpp
inline explicit json_binary_proxy(
    nlohmann::json & elem,
    fmt format
)
```


### function json_binary_proxy

```cpp
json_binary_proxy() =delete
```


### function json_binary_proxy

```cpp
json_binary_proxy(
    const json_binary_proxy & 
) =default
```


### function json_binary_proxy

```cpp
json_binary_proxy(
    json_binary_proxy && 
) =default
```


### function operator*

```cpp
inline nlohmann::json & operator*()
```

Dereferencing a proxy element accesses the underlying nlohmann::json. 

### function operator->

```cpp
inline nlohmann::json * operator->()
```


### function operator[]

```cpp
template <typename T >
inline json_binary_proxy operator[](
    T && key
)
```

Descends into the json object, returning a new binary value proxy around the child element. 

### function front

```cpp
inline json_binary_proxy front()
```

Returns a binary value proxy around the first/last element (requires an underlying list) 

### function back

```cpp
inline json_binary_proxy back()
```


### function operator=

```cpp
nlohmann::json & operator=(
    std::string_view binary_data
)
```

Assigns binary data from a string_view/string/etc. 

### function operator=

```cpp
template <typename Char ,
std::enable_if_t< sizeof(Char)==1 &&!std::is_same_v< Char, char >, int >  =0>
inline nlohmann::json & operator=(
    std::basic_string_view< Char > binary_data
)
```

Assigns binary data from a string_view over a 1-byte, non-char type (e.g. 

unsigned char or uint8_t). 


### function operator=

```cpp
template <typename T ,
std::enable_if_t< json_is_binary< T >, int >  =0>
inline nlohmann::json & operator=(
    const T & val
)
```

Takes a trivial, no-padding data structure (e.g. 

a crypto::hash) as the value and dumps its contents as the binary value. 


### function operator=

```cpp
template <typename T ,
std::enable_if_t< json_is_binary_container< T >, int >  =0>
inline nlohmann::json & operator=(
    const T & vals
)
```

Takes a vector of some json_binary_proxy-assignable type and builds an array by assigning each one into a new array of binary values. 

### function emplace_back

```cpp
template <typename... Args>
inline json_binary_proxy emplace_back(
    Args &&... args
)
```

Emplaces a new nlohman::json to the end of an underlying list and returns a [json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) wrapping it. 

Example: 

```
auto child = wrappedelem.emplace_back({"key1": 1}, {"key2": 2});
child["binary-key"] = some_binary_thing; 
```


### function push_back

```cpp
template <typename T >
inline void push_back(
    T && val
)
```

Adds an element to an underlying list, then copies or moves the given argument onto it via [json_binary_proxy](Classes/classllarp_1_1rpc_1_1json__binary__proxy.md) assignment. 

## Public Attributes Documentation

### variable e

```cpp
nlohmann::json & e;
```


### variable format

```cpp
enum llarp::rpc::json_binary_proxy::fmt format;
```


-------------------------------

Updated on 2023-01-26 at 19:35:17 +0000