c++编写json解析类(六)

2014-11-24 09:52:14 · 作者: · 浏览: 6
(m_par && (m_par->type==ARRAY || m_par->type==ARRAYA))
{
NODE *node=new NODE;
memset(node,0,sizeof(NODE));
node->type=LONGA;
node->m_parent=m_par;
m_cur=node;
if(m_par->m_child==0)
{
m_par->m_child=node;
}
else
{
NODE *n=m_par->m_child;
while(n->m_next)
{
n=n->m_next;
}
n->m_next=node;
}
if(m_str[i-1]=='-')
{
node->m_strVal+=m_str[i-1];
}
while(m_str[i]!=','&& m_str[i]!=']')
{
if(!CHECKBLANK(m_str[i]))
{
node->m_strVal+=m_str[i];
}
node->m_longVal=atoi(node->m_strVal.data());
i++;
}
i--;

}
else
{
m_cur->type=LONG;
if(m_str[i-1]=='-')
{
m_cur->m_strVal+=m_str[i-1];
}
while(m_str[i]!=','&& m_str[i]!=']' && m_str[i]!='}')
{
if(!CHECKBLANK(m_str[i]))
{
m_cur->m_strVal+=m_str[i];
}
m_cur->m_longVal=atoi(m_cur->m_strVal.data());
i++;
}
i--;

}

}
else if((m_str[i]>='a' && m_str[i]<='z') || (m_str[i]>='A' && m_str[i]<='Z'))
{
if(m_par && (m_par->type==ARRAY || m_par->type==ARRAYA))
{
NODE *node=new NODE;
memset(node,0,sizeof(NODE));
node->m_parent=m_par;
m_cur=node;
if(m_par->m_child==0)
{
m_par->m_child=node;
}
else
{
NODE *n=m_par->m_child;
while(n->m_next)
{
n=n->m_next;
}
n->m_next=node;
}
bool bInQ=false;
while(bInQ ||(m_str[i]!=','&& m_str[i]!=']'))
{
if(!CHECKBLANK(m_str[i]))
{
if(m_str[i]=='\"' || m_str[i]=='\'')
{
bInQ=!bInQ;
}
node->m_objVal+=m_str[i];
}