MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / write_ubjson

Method write_ubjson

native/thirdpart/json/json.hpp:11843–11996  ·  view source on GitHub ↗

! @param[in] j JSON value to serialize @param[in] use_count whether to use '#' prefixes (optimized format) @param[in] use_type whether to use '$' prefixes (optimized format) @param[in] add_prefix whether prefixes need to be used for this value */

Source from the content-addressed store, hash-verified

11841 @param[in] add_prefix whether prefixes need to be used for this value
11842 */
11843 void write_ubjson(const BasicJsonType& j, const bool use_count,
11844 const bool use_type, const bool add_prefix = true)
11845 {
11846 switch (j.type())
11847 {
11848 case value_t::null:
11849 {
11850 if (add_prefix)
11851 {
11852 oa->write_character(to_char_type('Z'));
11853 }
11854 break;
11855 }
11856
11857 case value_t::boolean:
11858 {
11859 if (add_prefix)
11860 {
11861 oa->write_character(j.m_value.boolean
11862 ? to_char_type('T')
11863 : to_char_type('F'));
11864 }
11865 break;
11866 }
11867
11868 case value_t::number_integer:
11869 {
11870 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
11871 break;
11872 }
11873
11874 case value_t::number_unsigned:
11875 {
11876 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
11877 break;
11878 }
11879
11880 case value_t::number_float:
11881 {
11882 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
11883 break;
11884 }
11885
11886 case value_t::string:
11887 {
11888 if (add_prefix)
11889 {
11890 oa->write_character(to_char_type('S'));
11891 }
11892 write_number_with_ubjson_prefix(j.m_value.string->size(), true);
11893 oa->write_characters(
11894 reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
11895 j.m_value.string->size());
11896 break;
11897 }
11898
11899 case value_t::array:
11900 {

Callers 1

to_ubjsonFunction · 0.80

Calls 6

emptyMethod · 0.80
write_characterMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected