mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 15:00:51 +01:00
ircd::json: Fixes to grammar and generator related.
This commit is contained in:
parent
6dbc9201f1
commit
03734c7fb5
1 changed files with 4 additions and 6 deletions
10
ircd/json.cc
10
ircd/json.cc
|
@ -350,7 +350,7 @@ const
|
||||||
{
|
{
|
||||||
const auto gg
|
const auto gg
|
||||||
{
|
{
|
||||||
maxwidth(stop - out)[std::forward<gen>(g)] | eps[failed_to_serialize_object]
|
maxwidth(size_t(stop - out))[std::forward<gen>(g)] | eps[failed_to_serialize_object]
|
||||||
};
|
};
|
||||||
|
|
||||||
return karma::generate(out, gg, std::forward<attr>(a));
|
return karma::generate(out, gg, std::forward<attr>(a));
|
||||||
|
@ -365,7 +365,7 @@ const
|
||||||
{
|
{
|
||||||
const auto gg
|
const auto gg
|
||||||
{
|
{
|
||||||
maxwidth(stop - out)[std::forward<gen>(g)] | eps[failed_to_serialize_object]
|
maxwidth(size_t(stop - out))[std::forward<gen>(g)] | eps[failed_to_serialize_object]
|
||||||
};
|
};
|
||||||
|
|
||||||
return karma::generate(out, gg);
|
return karma::generate(out, gg);
|
||||||
|
@ -690,7 +690,7 @@ ircd::json::obj::obj(recursive_t recursive,
|
||||||
const doc &doc)
|
const doc &doc)
|
||||||
:idx{doc.count()}
|
:idx{doc.count()}
|
||||||
{
|
{
|
||||||
static const auto transform([&]
|
std::transform(std::begin(doc), std::end(doc), std::begin(idx), [&]
|
||||||
(const doc::member &m) -> obj::member
|
(const doc::member &m) -> obj::member
|
||||||
{
|
{
|
||||||
switch(type(m.second))
|
switch(type(m.second))
|
||||||
|
@ -702,8 +702,6 @@ ircd::json::obj::obj(recursive_t recursive,
|
||||||
return obj::member{m};
|
return obj::member{m};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
std::transform(std::begin(doc), std::end(doc), std::begin(idx), transform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::json::obj::obj(const doc &doc)
|
ircd::json::obj::obj(const doc &doc)
|
||||||
|
@ -773,7 +771,7 @@ const
|
||||||
const auto &val(it->second);
|
const auto &val(it->second);
|
||||||
if(!indice.empty())
|
if(!indice.empty())
|
||||||
{
|
{
|
||||||
const auto idx(lex_cast<size_t>(chomp(indice, "]")));
|
const auto idx(lex_cast<size_t>(rstrip(indice, ']')));
|
||||||
|
|
||||||
if(type(val) != ARRAY)
|
if(type(val) != ARRAY)
|
||||||
throw not_found("cannot recurse through non-array \"%s\" for indice [%zu]", name, idx);
|
throw not_found("cannot recurse through non-array \"%s\" for indice [%zu]", name, idx);
|
||||||
|
|
Loading…
Reference in a new issue