You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note also that `read` and `write` methods of Reader_Writer class can be template methods.
1982
1979
1980
+
A custom Reader_Writer can also be used to change representation of a field. For example, let suppose that we have a `std::vector<some_struct>` field, but this field has to be represented as a single object if it holds just one value, and as an array otherwise. Something like:
1981
+
1982
+
```json
1983
+
{
1984
+
"message": {
1985
+
"from": "address-1",
1986
+
"to": "address-2",
1987
+
...,
1988
+
"extension": {...}
1989
+
},
1990
+
...
1991
+
}
1992
+
```
1993
+
1994
+
if we have only one extension in a message or:
1995
+
1996
+
```json
1997
+
{
1998
+
"message": {
1999
+
"from": "address-1",
2000
+
"to": "address-2",
2001
+
...,
2002
+
"extension": [
2003
+
{...},
2004
+
{...},
2005
+
...
2006
+
]
2007
+
},
2008
+
...
2009
+
}
2010
+
```
2011
+
2012
+
if there are several extensions.
2013
+
2014
+
A solution with a custom Reader_Writer can looks like:
0 commit comments