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

Implement std.objectValues and std.objectValuesAll #858

Merged
merged 1 commit into from
Oct 23, 2020

Conversation

tragiclifestories
Copy link
Contributor

Hello friends!

This PR adds two helper functions for extracting an array of values from an object. This was not impossible before (hence the implementations are in jsonnet), but I think it is worth having a 'first class' implementation - for further evidence, it is a very common feature of data transformation libraries.

It was mentioned in this comment.

@google-cla google-cla bot added the cla: yes label Oct 23, 2020
@@ -63,7 +63,7 @@ <h4 id="extVar">
<p>
If an external variable with the given name was defined, return its string value. Otherwise, raise an error.
</p>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about this noise - I have an vim trigger thing that deletes trailing whitespace ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't edit this file manually. Here are the instructions for updating stdlib docs: https://github.com/google/jsonnet#locally-serving-the-website.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that makes a lot more sense - updated.

Copy link
Collaborator

@sbarzowski sbarzowski left a comment

Choose a reason for hiding this comment

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

Thanks! This is a good addition to the standard library.

@@ -63,7 +63,7 @@ <h4 id="extVar">
<p>
If an external variable with the given name was defined, return its string value. Otherwise, raise an error.
</p>

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't edit this file manually. Here are the instructions for updating stdlib docs: https://github.com/google/jsonnet#locally-serving-the-website.

@@ -39,7 +39,7 @@ limitations under the License.
assert std.isString(str) : 'substr first parameter should be a string, got ' + std.type(str);
assert std.isNumber(from) : 'substr second parameter should be a string, got ' + std.type(from);
assert std.isNumber(len) : 'substr third parameter should be a string, got ' + std.type(len);
assert len >=0 : 'substr third parameter should be greater than zero, got ' + len;
assert len >= 0 : 'substr third parameter should be greater than zero, got ' + len;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes are also all autoformatting but they look like good changes? I can rebase and just take the actual stuff I added if you want.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, it looks like our own auto-formatting. Ideally that would be a separate commit, but that's not a big deal.

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

Successfully merging this pull request may close these issues.

2 participants