-
Notifications
You must be signed in to change notification settings - Fork 834
feat: Add FromJson markup extension #21875
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
Conversation
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.
Pull Request Overview
This PR adds a new JsonToObject markup extension to the Uno.UI.Toolkit, enabling developers to define structured sample data directly in XAML using JSON strings. The extension parses JSON payloads into dynamic object graphs (ExpandoObject and List<object?>) that can be bound to UI elements, eliminating the need for temporary view model classes during development and testing.
Key changes:
- New
JsonToObjectExtensionmarkup extension that converts JSON strings to dynamic objects - Internal
JsonToObjectParserutility for JSON-to-object conversion with flexible parsing options - XAML builder enhancement to support both
JsonToObjectandJsonToObjectExtensionsyntax - Comprehensive runtime tests validating JSON parsing, binding, and error scenarios
- Documentation with usage examples
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectBuilder.cs |
Adds fallback logic to resolve properties on markup extension types with "Extension" suffix, enabling standard XAML markup extension naming conventions |
src/Uno.UI.Toolkit/Markup/JsonToObjectParser.cs |
Internal parser that converts JSON documents into dynamic object graphs using ExpandoObject for objects and List for arrays, with support for trailing commas and comments |
src/Uno.UI.Toolkit/Markup/JsonToObjectExtension.cs |
Markup extension implementation with ContentProperty attribute on Json property, providing JSON-to-object conversion with XamlParseException error handling |
src/Uno.UI.RuntimeTests/Tests/Uno_UI_Toolkit/Given_JsonToObject.cs |
Runtime tests covering basic JSON parsing, nested objects, arrays, ItemsControl binding, and error scenarios for invalid/empty JSON |
doc/articles/Uno.UI.Toolkit.md |
User documentation explaining the JsonToObject markup extension with a complete usage example showing JSON resource definition and binding |
|
π€ Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21875/docs/index.html |
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
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.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
|
π€ Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21875/docs/index.html |
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
|
π€ Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21875/docs/index.html |
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
|
@mergify backport release/stable/6.4 |
β Backports have been createdDetails
|
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
|
|
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
899dbaf to
3315cb0
Compare
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
3315cb0 to
400572f
Compare
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
|
π€ Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21875/docs/index.html |
|
π€ Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21875/wasm-skia-net9/index.html |
|
The build 183819 found UI Test snapshots differences: Details
|
β¦6.4/pr-21875 feat: Add FromJson markup extension (backport #21875)
PR Type:
What is the new behavior? π
Adds a new JsonToObject in order load a DataContext object from a literal string in XAML resources.
PR Checklist β
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information βΉοΈ