-
Notifications
You must be signed in to change notification settings - Fork 11
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
Document additional commonly-used cJSON functions and types. #145
Conversation
n_cjson_helpers.c
Outdated
/**************************************************************************/ | ||
@brief Determine if a field is present in a JSON object. | ||
|
||
@param rsp The JSON object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're changing things, should we go ahead and rename this parameter j
or json
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would also be nice to have a note describing that false
is returned if the JSON object is NULL
?
This would allow folks to program against it, instead of guess.
n_cjson_helpers.c
Outdated
/**************************************************************************/ | ||
@brief Get the value of a string field from a JSON object. | ||
|
||
@param rsp The JSON object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j
or json
n_cjson_helpers.c
Outdated
/**************************************************************************/ | ||
@brief Get the value of an array field from a JSON object. | ||
|
||
@param rsp The JSON object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j
or json
n_cjson_helpers.c
Outdated
@param field The array field to query. | ||
|
||
@returns A pointer to the array, which is itself a JSON object (`J *`), if the | ||
field exists and is an array and NULL otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading this one, "and and...", made me realize a function only returns one OR the other. It also reads a little easier in my opinion, so I added it to others above.
field exists and is an array and NULL otherwise. | |
field exists and is an array, or NULL otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna go with "otherwise NULL." I like removing "and", but I feel like "or" and "otherwise" together is wordy and sort of feels redundant.
n_cjson_helpers.c
Outdated
@param rsp The JSON object. | ||
@param field The string field to query. | ||
|
||
@returns A pointer to the string if the field exists and is a string and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@returns A pointer to the string if the field exists and is a string and the | |
@returns A pointer to the string if the field exists and is a string, or an |
n_cjson_helpers.c
Outdated
@returns True if the string was successfully encoded and added to the object | ||
and false otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@returns True if the string was successfully encoded and added to the object | |
and false otherwise. | |
@returns True if the string was successfully encoded and added to the object, | |
or false otherwise. |
n_cjson_helpers.c
Outdated
|
||
@param rsp The JSON object. | ||
@param fieldName The name of the field. | ||
@param retBinaryData A pointer to a buffer to hold the decoded bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param retBinaryData A pointer to a buffer to hold the decoded bytes. | |
@param retBinaryData A pointer to a pointer, used to hold the pointer to the decoded bytes. |
n_cjson_helpers.c
Outdated
@param retBinaryDataLen A pointer to a number to hold the length of the decoded | ||
bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param retBinaryDataLen A pointer to a number to hold the length of the decoded | |
bytes. | |
```suggestion | |
@param retBinaryDataLen A pointer to an unsigned integer, used to hold the | |
length of the decoded bytes. |
n_cjson_helpers.c
Outdated
@param retBinaryDataLen A pointer to a number to hold the length of the decoded | ||
bytes. | ||
|
||
@returns True if the string was successfully decoded and returned and false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@returns True if the string was successfully decoded and returned and false | |
@returns True if the string was successfully decoded and returned, or false |
No description provided.