Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cJSON_strcasecmp:converted to lower case for comparison #13

Closed
AtingTot opened this issue Jun 3, 2016 · 8 comments
Closed

cJSON_strcasecmp:converted to lower case for comparison #13

AtingTot opened this issue Jun 3, 2016 · 8 comments
Milestone

Comments

@AtingTot
Copy link

AtingTot commented Jun 3, 2016

Why is converted to lower case for comparison?
Cause xxxxx and XXXXX two nodes can not be normal access。

@DaveGamble
Copy link
Owner

Don’t you feel like you might be tempting fate with two nodes with the same name but different case? Is that terrific data design?

But hey, if you want to go that route, I won’t stop you! Have the following three routines and forget about case insensitivity forever! But unless I’ve misread the JSON spec, I won't be adding them to HEAD any time soon.

cJSON *cJSON_GetObjectItemCASE(cJSON *object,const char *string) {cJSON *c=object?object->child:0;while (c && strcmp(c->string,string)) c=c->next; return c;}

cJSON *cJSON_DetachItemFromObjectCASE(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && strcmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}

void cJSON_ReplaceItemInObjectCASE(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && strcmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}

On 3 Jun 2016, at 04:34, xichen124 notifications@github.com wrote:

Why is converted to lower case for comparison?
Cause xxxxx and XXXXX two nodes can not be normal access。


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@AtingTot
Copy link
Author

AtingTot commented Jun 3, 2016

Thanks. But aaaaa(this is lower case) and AAAAA(this is upper case),they are different strings.
cJSON use cJSON_strcasecmp but not strcmp to compare the two strings。If aaaaa was in front and AAAAA was behind, I can only find through the aaaaa to AAAAA, and can not find AAAAA. You can try it.

@DaveGamble
Copy link
Owner

DaveGamble commented Jun 3, 2016

Closed.

@AtingTot
Copy link
Author

Sorry! I read it, but i did not understand. Now i understand.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Nov 7, 2016

@DaveGamble: Where does the JSON Spec say that object names are case insensitive? As far as I can see it only specifies that it has to be a valid JSON string: http://rfc7159.net/rfc7159#rfc.section.4

@FSMaxB FSMaxB reopened this Nov 7, 2016
@FSMaxB FSMaxB added this to the 1.0.0 milestone Nov 7, 2016
@DaveGamble
Copy link
Owner

Presumably I misread the JSON spec then.
The RFC at the time of writing was: https://www.ietf.org/rfc/rfc4627.txt

However, I seem to remember there being some discussion about this on the JSON mailing list.
The decision was made on the basis that the point of JSON (and cJSON) was to be simple, and case insensitivity would work in that direction.

Changing to case sensitivity MIGHT break a lot of code. Or none at all?! How would we know?

@FSMaxB
Copy link
Collaborator

FSMaxB commented Nov 7, 2016

Ok, let's make a legacy release. Let's say 0.0.0, of the current master (after resolving issue #26). That would contain cJSON as it is, only security fixes will be applied. People who are concerned about compatibility with broken JSON can then use that for the time being. And then we can break all we want in the 1.0.0 release.

@FSMaxB FSMaxB mentioned this issue Nov 12, 2016
11 tasks
@FSMaxB
Copy link
Collaborator

FSMaxB commented Nov 13, 2016

Fixed on the road-to-release branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants