Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLAScommon
Commits
a708c3ab
Commit
a708c3ab
authored
Jul 27, 2020
by
Steffen Vogel
🎅🏼
Browse files
buffer: allow JSON indention
parent
9ea08ef8
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/villas/buffer.hpp
View file @
a708c3ab
...
...
@@ -48,7 +48,7 @@ public:
int
parseJson
(
json_t
**
j
);
int
appendJson
(
json_t
*
j
);
int
appendJson
(
json_t
*
j
,
int
flags
=
JSON_INDENT
(
4
)
);
};
}
/* namespace villas */
include/villas/json_buffer.hpp
View file @
a708c3ab
...
...
@@ -39,7 +39,7 @@ protected:
public:
/** Encode JSON document /p j and append it to the buffer */
int
encode
(
json_t
*
j
);
int
encode
(
json_t
*
j
,
int
flags
=
JSON_INDENT
(
4
)
);
/** Decode JSON document from the beginning of the buffer */
json_t
*
decode
();
...
...
lib/buffer.cpp
View file @
a708c3ab
...
...
@@ -75,11 +75,11 @@ int Buffer::parseJson(json_t **j)
return
0
;
}
int
Buffer
::
appendJson
(
json_t
*
j
)
int
Buffer
::
appendJson
(
json_t
*
j
,
int
flags
)
{
size_t
l
;
retry:
l
=
json_dumpb
(
j
,
buf
+
len
,
size
-
len
,
0
);
retry:
l
=
json_dumpb
(
j
,
buf
+
len
,
size
-
len
,
flags
);
if
(
size
<
len
+
l
)
{
buf
=
(
char
*
)
realloc
(
buf
,
len
+
l
);
if
(
!
buf
)
...
...
lib/json_buffer.cpp
View file @
a708c3ab
...
...
@@ -40,9 +40,9 @@ json_t * JsonBuffer::decode()
return
j
;
}
int
JsonBuffer
::
encode
(
json_t
*
j
)
int
JsonBuffer
::
encode
(
json_t
*
j
,
int
flags
)
{
return
json_dump_callback
(
j
,
callback
,
this
,
0
);
return
json_dump_callback
(
j
,
callback
,
this
,
flags
);
}
int
JsonBuffer
::
callback
(
const
char
*
data
,
size_t
len
,
void
*
ctx
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment