if pt::Space has FT::json type then let JSONExpression serialize it as json and not string

This commit is contained in:
Tomasz Sowa 2022-02-03 11:18:01 +01:00
parent c25a5d2215
commit 48d515ea64
2 changed files with 38 additions and 0 deletions

View File

@ -99,6 +99,24 @@ void JSONExpression::after_field_value_string(const FT & field_type)
}
void JSONExpression::before_field_value(const pt::Space &, const FT & field_type)
{
if( field_type.is_space() )
{
before_field_value_string(field_type);
}
}
void JSONExpression::after_field_value(const pt::Space &, const FT & field_type)
{
if( field_type.is_space() )
{
after_field_value_string(field_type);
}
}
void JSONExpression::put_name_value_separator()
{
(*out_stream) << ':';
@ -130,4 +148,20 @@ void JSONExpression::esc(char val, pt::TextStream & stream, const FT & field_typ
}
void JSONExpression::esc(const pt::Space & space, pt::TextStream & stream, const FT & field_type)
{
bool pretty_print = field_type.is_pretty_print();
if( field_type.is_space() )
{
pt::WTextStream tmp_stream;
space.serialize_to_space_stream(tmp_stream, pretty_print);
BaseExpression::esc(tmp_stream, stream, field_type);
}
else
{
space.serialize_to_json_stream(stream, pretty_print);
}
}
}

View File

@ -73,6 +73,10 @@ private:
void before_field_value_string(const FT & field_type);
void after_field_value_string(const FT & field_type);
void before_field_value(const pt::Space &, const FT & field_type);
void after_field_value(const pt::Space &, const FT & field_type);
void esc(const pt::Space & space, pt::TextStream & stream, const FT & field_type);
};