当前位置: 代码迷 >> Symbian >> 提取解决方案
  详细解决方案

提取解决方案

热度:3298   发布时间:2013-02-26 00:00:00.0
提取
大家好,怎么在Symbian中把{\"key_duration\":3600,\"newversion\":true,\"ss_key\":\"de36d72ec107e9d12833b7b04541f0d8\",\"ss_ip\":\"223.4.10.125\",\"ss_port\":30002,\"url\":\"http://223.4.10.125/welcome/download?soft=android&from=client&version=130\"}里面的ss_key,ss_ip,ss_port中这三个值取出来
------解决方案--------------------------------------------------------
没人吗?
------解决方案--------------------------------------------------------



#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const char* token[3]=
{
        "ss_key\":\"",
        "ss_ip\":\"",
        "ss_port\":"
};

 char endMark[3]={'"','"',','};

#define MAX_VALUE_SIZE 50

int parse( char *input,char output[][MAX_VALUE_SIZE])      
{
        char *curIndex=input;
        int inputLen=strlen(input);

        for(int i=0;i<3;++i)
        {
                curIndex=strstr(curIndex,token[i]);

                if(curIndex==NULL)
                {
                        return -1;
                }

                curIndex+=strlen(token[i]);
                 char *end=strchr(curIndex,endMark[i]);

                if(end==NULL)
                {
                        return -1;
                }

                strncpy(output[i],curIndex,end-curIndex);
                output[i][end-curIndex]='\0';
                curIndex=end+1;
        }

        return 0;
}


int _tmain(int argc, _TCHAR* argv[])
{
  char *input="{\"key_duration\":3600,\"newversion\":true,\"ss_key\":\"993b4b3fb795017c923004f12aa64244\",\"ss_ip\":\"223.4.10.125\",\"ss_port\":30002,\"url\":\"http://223.4.10.125/welcome/download?soft=android&from=client&version=130\"}";

        char output[3][MAX_VALUE_SIZE];


        if(parse(input,output)==0)
        {
               
  相关解决方案