mirror of
https://github.com/DaveGamble/cJSON
synced 2025-01-03 04:42:27 +00:00
make these PROPERLY ansi-c compliant ;)
git-svn-id: http://svn.code.sf.net/p/cjson/code@2 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
parent
805b652e51
commit
a4a4e7cbff
8
cJSON.c
8
cJSON.c
@ -354,7 +354,7 @@ cJSON *cJSON_CreateArray() {cJSON *item=cJSON_New_Item();item->type=cJSON_A
|
|||||||
cJSON *cJSON_CreateObject() {cJSON *item=cJSON_New_Item();item->type=cJSON_Object;return item;}
|
cJSON *cJSON_CreateObject() {cJSON *item=cJSON_New_Item();item->type=cJSON_Object;return item;}
|
||||||
|
|
||||||
// Create Arrays:
|
// Create Arrays:
|
||||||
cJSON *cJSON_CreateIntArray(int *numbers,int count) {cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(int i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
cJSON *cJSON_CreateIntArray(int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||||
cJSON *cJSON_CreateFloatArray(float *numbers,int count) {cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(int i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
cJSON *cJSON_CreateFloatArray(float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||||
cJSON *cJSON_CreateDoubleArray(double *numbers,int count) {cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(int i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
cJSON *cJSON_CreateDoubleArray(double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||||
cJSON *cJSON_CreateStringArray(const char **strings,int count) {cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(int i=0;i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||||
|
2
test.c
2
test.c
@ -102,7 +102,7 @@ void create_objects()
|
|||||||
{"zip",37.371991,-1.22026e+2,"","SUNNYVALE","CA","94085","US"}};
|
{"zip",37.371991,-1.22026e+2,"","SUNNYVALE","CA","94085","US"}};
|
||||||
|
|
||||||
root=cJSON_CreateArray();
|
root=cJSON_CreateArray();
|
||||||
for (int i=0;i<2;i++)
|
for (i=0;i<2;i++)
|
||||||
{
|
{
|
||||||
cJSON_AddItemToArray(root,fld=cJSON_CreateObject());
|
cJSON_AddItemToArray(root,fld=cJSON_CreateObject());
|
||||||
cJSON_AddItemToObject(fld, "precision", cJSON_CreateString(fields[i].precision));
|
cJSON_AddItemToObject(fld, "precision", cJSON_CreateString(fields[i].precision));
|
||||||
|
Loading…
Reference in New Issue
Block a user