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

Document additional commonly-used cJSON functions and types. #145

Merged
merged 2 commits into from
Apr 18, 2024

Conversation

haydenroche5
Copy link
Collaborator

No description provided.

@haydenroche5 haydenroche5 self-assigned this Mar 26, 2024
/**************************************************************************/
@brief Determine if a field is present in a JSON object.

@param rsp The JSON object.
Copy link
Collaborator

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?

Copy link
Collaborator

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.

/**************************************************************************/
@brief Get the value of a string field from a JSON object.

@param rsp The JSON object.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j or json

/**************************************************************************/
@brief Get the value of an array field from a JSON object.

@param rsp The JSON object.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j or json

@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.
Copy link
Collaborator

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.

Suggested change
field exists and is an array and NULL otherwise.
field exists and is an array, or NULL otherwise.

Copy link
Collaborator Author

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.

@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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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

Comment on lines 363 to 364
@returns True if the string was successfully encoded and added to the object
and false otherwise.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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.


@param rsp The JSON object.
@param fieldName The name of the field.
@param retBinaryData A pointer to a buffer to hold the decoded bytes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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.

Comment on lines 394 to 395
@param retBinaryDataLen A pointer to a number to hold the length of the decoded
bytes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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.

@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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@returns True if the string was successfully decoded and returned and false
@returns True if the string was successfully decoded and returned, or false

n_cjson_helpers.c Show resolved Hide resolved
@haydenroche5 haydenroche5 merged commit 168490e into blues:master Apr 18, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants