Exemplo n.º 1
0
static void s_Repr_Array(CNcbiOstrstream& oss, const CJsonNode& node)
{
    CJsonIterator it = node.Iterate();
    if (it) {
        s_Repr_Value(oss, *it);
        while (++it) {
            oss << ", ";
            s_Repr_Value(oss, *it);
        }
    }
}
Exemplo n.º 2
0
static void s_Repr_Object(CNcbiOstrstream& oss, const CJsonNode& node)
{
    CJsonIterator it = node.Iterate();
    if (it) {
        oss << '"' << it.GetKey() << "\": ";
        s_Repr_Value(oss, *it);
        while (++it) {
            oss << ", \"" << it.GetKey() << "\": ";
            s_Repr_Value(oss, *it);
        }
    }
}
Exemplo n.º 3
0
bool CJsonOverUTTPWriter::x_SendNode(const CJsonNode& node)
{
    switch (node.GetNodeType()) {
    case CJsonNode::eObject:
        x_PushNode(node);
        m_CurrentOutputNode.m_Iterator = node.Iterate();
        m_SendHashValue = false;
        return m_UTTPWriter.SendControlSymbol('{');

    case CJsonNode::eArray:
        x_PushNode(node);
        m_CurrentOutputNode.m_Iterator = node.Iterate();
        return m_UTTPWriter.SendControlSymbol('[');

    case CJsonNode::eString:
        {
            const string& str(static_cast<const SJsonStringNodeImpl*>(
                (const SJsonNodeImpl*) node)->m_String);
            return m_UTTPWriter.SendChunk(str.data(), str.length(), false);
        }

    case CJsonNode::eInteger:
        return m_UTTPWriter.SendNumber(node.AsInteger());

    case CJsonNode::eDouble:
        m_Double = node.AsDouble();
        if (!m_UTTPWriter.SendControlSymbol(DOUBLE_PREFIX)) {
            x_PushNode(node);
            return false;
        }
        return m_UTTPWriter.SendRawData(&m_Double, sizeof(m_Double));

    case CJsonNode::eBoolean:
        return m_UTTPWriter.SendControlSymbol(node.AsBoolean() ? 'Y' : 'N');

    default: /* case CJsonNode::eNull: */
        return m_UTTPWriter.SendControlSymbol('U');
    }
}
Exemplo n.º 4
0
 SFlattenIterator(const CJsonNode& container)
 {
     m_CurrentFrame.m_Iterator = container.Iterate();
     m_CurrentFrame.m_Index = container.IsObject() ? (size_t) -1 : 0;
     x_DepthFirstSearchForScalar();
 }