void PublishToIoTCoreRequest::SerializeToJsonObject()

in greengrass_ipc/source/GreengrassCoreIpcModel.cpp [4620:4677]


        void PublishToIoTCoreRequest::SerializeToJsonObject(Aws::Crt::JsonObject &payloadObject) const noexcept
        {
            if (m_topicName.has_value())
            {
                payloadObject.WithString("topicName", m_topicName.value());
            }
            if (m_qos.has_value())
            {
                payloadObject.WithString("qos", m_qos.value());
            }
            if (m_payload.has_value())
            {
                if (m_payload.value().size() > 0)
                {
                    payloadObject.WithString("payload", Aws::Crt::Base64Encode(m_payload.value()));
                }
            }
            if (m_retain.has_value())
            {
                payloadObject.WithBool("retain", m_retain.value());
            }
            if (m_userProperties.has_value())
            {
                Aws::Crt::JsonObject listOfUserProperties;
                Aws::Crt::Vector<Aws::Crt::JsonObject> listOfUserPropertiesJsonArray;
                for (const auto &listOfUserPropertiesItem : m_userProperties.value())
                {
                    Aws::Crt::JsonObject listOfUserPropertiesJsonArrayItem;
                    listOfUserPropertiesItem.SerializeToJsonObject(listOfUserPropertiesJsonArrayItem);
                    listOfUserPropertiesJsonArray.emplace_back(std::move(listOfUserPropertiesJsonArrayItem));
                }
                listOfUserProperties.AsArray(std::move(listOfUserPropertiesJsonArray));
                payloadObject.WithObject("userProperties", std::move(listOfUserProperties));
            }
            if (m_messageExpiryIntervalSeconds.has_value())
            {
                payloadObject.WithInt64("messageExpiryIntervalSeconds", m_messageExpiryIntervalSeconds.value());
            }
            if (m_correlationData.has_value())
            {
                if (m_correlationData.value().size() > 0)
                {
                    payloadObject.WithString("correlationData", Aws::Crt::Base64Encode(m_correlationData.value()));
                }
            }
            if (m_responseTopic.has_value())
            {
                payloadObject.WithString("responseTopic", m_responseTopic.value());
            }
            if (m_payloadFormat.has_value())
            {
                payloadObject.WithString("payloadFormat", m_payloadFormat.value());
            }
            if (m_contentType.has_value())
            {
                payloadObject.WithString("contentType", m_contentType.value());
            }
        }