dodyg/practical-aspnetcore

Add samples for System.Text.Json writable DOM

dodyg opened this issue · 13 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 ?

dodyg commented

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?

dodyg commented

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.

dodyg commented

This adds the sample of accessing primitives from JSON string

1da2bfc

dodyg commented

This adds a sample about accessing object and using JsonObject.

7a766b5

dodyg commented

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

9704265

dodyg commented

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

4f3e6e5

dodyg commented

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

eec8a4c

dodyg commented

This shows how to create a document using JsonObject 195178c

dodyg commented

This shows how to create a document with JsonArray 7215c50

dodyg commented

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

dodyg commented

Delete elements in a document 809fc40

dodyg commented

Add elements into a JSON array 968a1f1