dodyg / practical-aspnetcore

Practical samples of ASP.NET Core 8.0, 7.0, 6.0, 5.0, 3.1, 2.2, and 2.1,projects you can use. Readme contains explanations on all projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add samples for System.Text.Json writable DOM

dodyg opened this issue · comments

Whats your idea on this ? I mean - if we were to showcase this i.e. System.Text.Json writable dom - in ASP.NET Core - what sample idea works ?

One of the primary usage for this writable DOM is the ability to modify an existing JSON document without deserializing them into objects and then serializing it again.
For example https://gist.github.com/keeguon/2310008. How would you add "wakanda" into this list of countries?

We can make the following samples

  • Find a simple node and update its value
  • Find a nested object node and update one of its value
  • Find a nested object node and replace it
  • Append an item at the end an array.
  • Insert an item an n position in an array
  • Replace an item in an array.
  • Find an object within an array and replace one of its value
  • Replace a property of number and change it to a string value

There are probably more granular examples we can create.

This adds the sample of accessing primitives from JSON string

1da2bfc

This adds a sample about accessing object and using JsonObject.

7a766b5

This adds a sample on how to find a node based on one of its value

9704265

This is a slightly more complex node LINQ search on a string property and an array

4f3e6e5

This LINQ search try to find a node that doesn't have a particular property

eec8a4c

This shows how to create a document using JsonObject 195178c

This shows how to create a document with JsonArray 7215c50

This shows how to update properties of a JSON document 9b10602

Delete elements in a document 809fc40

Add elements into a JSON array 968a1f1