Skip to content

Update resp2_replies.json about JSON.CLEAR#286

Open
momadvisor wants to merge 2 commits into
valkey-io:mainfrom
momadvisor:for-docs-update
Open

Update resp2_replies.json about JSON.CLEAR#286
momadvisor wants to merge 2 commits into
valkey-io:mainfrom
momadvisor:for-docs-update

Conversation

@momadvisor
Copy link
Copy Markdown

fix a wrong and add a new

fix  a wrong and add a new

Signed-off-by: momadvisor <77181890+momadvisor@users.noreply.github.com>
make more concrete 

Signed-off-by: momadvisor <77181890+momadvisor@users.noreply.github.com>
Comment thread resp2_replies.json
" * The number of containers cleared.",
" * Returns 0 if clearing an empty array or object.",
" * Returns 0 if clearing a non-container value.",
" * Returns 0 if clearing a non-container value except JSON string.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure if we need this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
" * Returns 0 if clearing a non-container value except JSON string.",
" * Returns 0 if clearing a non-container value.",

Comment thread resp2_replies.json
" * Returns 0 if clearing a non-container value.",
" * Returns 0 if clearing a non-container value except JSON string.",
" * Returns 0 if no array or object value is located by the path.",
" * Always Returns 1 if clearing a JSON string value regardless of the length of the JSON string value including empty string.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
" * Always Returns 1 if clearing a JSON string value regardless of the length of the JSON string value including empty string.",
" *Returns 1 when clearing a JSON value.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it return the count of values, so this is incorrect.

@zuiderkwast zuiderkwast changed the title Update resp2_replies.json Update resp2_replies.json about JSON.CLEAR Sep 5, 2025
Copy link
Copy Markdown
Member

@roshkhatri roshkhatri left a comment

Choose a reason for hiding this comment

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

We will also need to edit the resp3_replies.json

dom_clear:

} else if (v.first->IsBool()) {
    if (v.first->IsTrue()) {
        v.first->SetBool(false);          // true  --> false   (counted)
        elements_cleared++;
    }
} else if (v.first->IsInt()) {
    if (v.first->GetInt() != 0) {
        v.first->SetInt(0);               // non-zero int --> 0  (counted)
        elements_cleared++;
    }
} else if (v.first->IsInt64())  { if (... != 0) { SetInt64(0);  ... } }
} else if (v.first->IsUint())   { if (... != 0) { SetUint(0);   ... } }
} else if (v.first->IsUint64()) { if (... != 0) { SetUint64(0); ... } }
} else if (v.first->IsDouble()) {
    if (GetDouble() < 0.0 || GetDouble() > 0.0) {
        v.first->SetDouble("0.0", 3, allocator);  // non-zero double --> 0.0 (counted)
        elements_cleared++;
    }
}

Comment thread resp2_replies.json
Comment on lines 747 to 748
" * The number of containers cleared.",
" * Returns 0 if clearing an empty array or object.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
" * The number of containers cleared.",
" * Returns 0 if clearing an empty array or object.",
" * The number of values cleared.",
" * A value is counted only when clearing changes it: a non-empty array or object is emptied, a non-empty string is set to empty, a non-zero number is set to 0, and true is set to false.",
" * Returns 0 for a value already empty, zero, false, or null.",

Comment thread resp2_replies.json
" * Returns 0 if clearing a non-container value.",
" * Returns 0 if clearing a non-container value except JSON string.",
" * Returns 0 if no array or object value is located by the path.",
" * Always Returns 1 if clearing a JSON string value regardless of the length of the JSON string value including empty string.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it return the count of values, so this is incorrect.

Comment thread resp2_replies.json
" * Returns 0 if clearing a non-container value.",
" * Returns 0 if clearing a non-container value except JSON string.",
" * Returns 0 if no array or object value is located by the path.",
" * Always Returns 1 if clearing a JSON string value regardless of the length of the JSON string value including empty string.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
" * Always Returns 1 if clearing a JSON string value regardless of the length of the JSON string value including empty string.",

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.

3 participants