-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Add-default-to-from-json #39405
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
Add-default-to-from-json #39405
Conversation
✅ Deploy Preview for home-assistant-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughThe documentation for templating has been updated to include an explanation and usage example for the Changes
Sequence Diagram(s)No sequence diagram generated as the change is documentation-only. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
source/_docs/configuration/templating.markdown (2)
905-906
: Typographical consistency: replacejson
withJSON
and refer to it as a filter
To align with existing docs, capitalize “JSON” and callfrom_json
a filter rather than a function.Apply this diff:
- `from_json(default)` function will attempt to convert the input to `json`. If that fails, returns the `default` value, or if omitted raises an error. + `from_json(default)` filter will attempt to deserialize the input as JSON. If that fails, it returns the provided `default` value; if no default is given, it raises an error.
907-927
: Differentiate duplicate “#### Template” and “#### Output” headings
Markdownlint flags multiple identical headings (MD024). Rename these to avoid collisions with prior examples, for instance:#### Template (with fallback) ... #### Output (with fallback)🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
907-907: Multiple headings with the same content
null(MD024, no-duplicate-heading)
918-918: Multiple headings with the same content
null(MD024, no-duplicate-heading)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
source/_docs/configuration/templating.markdown
(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
source/_docs/configuration/templating.markdown
907-907: Multiple headings with the same content
null
(MD024, no-duplicate-heading)
918-918: Multiple headings with the same content
null
(MD024, no-duplicate-heading)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - home-assistant-docs
- GitHub Check: Header rules - home-assistant-docs
- GitHub Check: Pages changed - home-assistant-docs
Proposed change
Add a default to from_json instead of producing an error.
e.g.
{{ "is this valid json" | from_json("no") }}
will return "no" because it's not valid json instead of producing JSON decoding errors.
Type of change
current
branch).current
branch).next
branch).next
branch).Additional information
Checklist
current
branch.next
branch.Summary by CodeRabbit
from_json(default)
function in the templating documentation.