當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
拼接JSON字符串
? ? ? ? ? ? ? ?傳輸數(shù)據(jù)時經(jīng)常要用到JSON格式,拼接JSON字符串是常用的事,這里記錄一下,直接看代碼吧。
[mapan@localhost unixNetwork]$ cat test.cpp #include<stdio.h> #include<string.h> void func(char test1[],char test2[],char test3[]) {char test[100];sprintf(test,"{\r\n meida_code:\"%s\",\\r\n app_id:\"%s\",\\r\n user_id:\"%s\",\\r\n}",test1,test2,test3);printf("%s\n",test); }int main() { char str1[]="1";char str2[]="2";char str3[]="3";func(str1,str2,str3);return 0; } [mapan@localhost unixNetwork]$ g++ test.cpp [mapan@localhost unixNetwork]$ ./a.out {meida_code:"1", app_id:"2", user_id:"3", } [mapan@localhost unixNetwork]$
總結(jié)
- 上一篇: shutdown函数和FIN_WAIT2
- 下一篇: gradle idea java ssm