c++ - Json: Unicode charecter '%' escapes at the end of the statement -


in code when try print '%' character on command line escapes(i.e not printed on command prompt), believe json compiler escaping character.

i using cajun - c++ source code json

what should retain '%' character. below snippet of code , writter.cpp

code snippet:

progval = mrldprogress_.fgi.reprogress.progress; objvd["progress%"] = json::number((int)((u32)(progval)* 100 /0xffff));     if(progval == 0xffff)     {         objvd["status"] =json::string("completed");         objvd["estimated time left"] = json::string("-");     }     else     {         objvd["status"] =json::string("in progress");     } 

code snippet of writter.cpp prints json "name":"value" :

if(it->name != "my message" && it->name != "begin table" && it->name != "end table")         {             if(neednewline){ writer::putchar(','); writer::putchar('\n'); neednewline=false;}              int tabs=m_ntabdepth; while(tabs) { writer::putchar('\t'); --tabs; } writer::putchar('"');              if(it->name.c_str()[it->name.length()-1]=='&') it->name = it->name.substr(0,it->name.length()-1);                         writer::printf("%s%s",it->name.c_str(),"\" : ");              write_i(it->element);             neednewline=true;         }  int writer::printf(const char *format, ...) {     char buff[4096];     char *ptr=buff;      if(!format) return 0;      va_list args;     va_start(args, format); #ifndef os_preboot     int ret = vsprintf(buff,format,args); #else     int ret = print(&ptr,format,args); #endif     va_end(args);      cache_string(buff);      return ret; } 

the string"progress%" actual culprit here, progress printed escaping % character.

i have tried adding control character "\" below line

> writer::printf("%s%s",it->name.c_str(),"\" : "); 

so % symbol gets printed on command prompt compiler error.

so please me regarding issue.

and when add '%\' in above statement works, symbol % printed on command prompt.

output of issue :

{ "my operation":[ {         "operation status" : {                 "count of operation" : 0,                 "status" : "success",                 "description" : "none"         },         "response data" : {                 "count operation status" : [                         {                                 "count" : 0,                                 "operation" : "init",                                 "progress" : "-",                                 "status" : "not in progress",                         }                 ]         } } ] }  

as can see in output progress% not displaying progress displaying.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -