Skip to main content

87 posts tagged with "JSON"

JSON Data Format, Parsing, and Serialization

View All Tags

How to Save Your Own Types in Microsoft Agent Framework Workflow Checkpoints in C#

· 18 min read
Jagdish Kumawat
Founder @ Dewiride

When a Microsoft Agent Framework workflow saves its checkpoints as JSON, each checkpoint holds the messages on their way between steps, including messages of types you wrote yourself. CheckpointManager.CreateJson takes JSON options for those types, and a JsonSerializerContext supplies them. Here's one small workflow run three ways: as a new console app runs it, with reflection-based JSON turned off, and with a context.

How to Store Dates and Times That Sort Correctly in Azure Cosmos DB with C#

· 15 min read
Jagdish Kumawat
Founder @ Dewiride

A C# DateTime that the Azure Cosmos DB SDK stores for you can sort in the wrong order: in this run, ORDER BY c.at listed an event at 10:00:00.5 before one at 10:00:00. Storing each time as a UTC string with seven digits after the seconds, the format Microsoft recommends, puts them back in the order they happened.

How to Exclude a Property from Indexing in Azure Cosmos DB with the Azure CLI

· 15 min read
Jagdish Kumawat
Founder @ Dewiride

Azure Cosmos DB indexes every property of every item you write, unless you tell it otherwise. When no query ever filters or sorts on a property, such as an article's long body text, an indexing policy can leave it out of the index. Here's how to write that policy as a JSON file and apply it with the Azure CLI, to a new container and to one that already exists.

How to Change Only Some Properties of an Azure Cosmos DB Item with PatchItemAsync in C#

· 14 min read
Jagdish Kumawat
Founder @ Dewiride

PatchItemAsync changes only the properties you name in an Azure Cosmos DB item: your app sends the changes, and Cosmos DB applies them to the stored item. Here one call lowers a product's price, takes three pens off its stock and adds a tag, in a small C# app, with what Cosmos DB answered.

How to Query the USGS Earthquake API with curl

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

The U.S. Geological Survey (USGS) publishes every earthquake it records worldwide through a free web API, with no account and no key. Ask it how many earthquakes happened on a day, or for a list of the strong ones, and it answers in a second. This guide asks it with curl in the terminal, and shows the one quoting rule that makes or breaks these commands.