Skip to content

Instantly share code, notes, and snippets.

View jbollman7's full-sized avatar

Joseph Bollman jbollman7

  • Northern Colorado
View GitHub Profile
@jbollman7
jbollman7 / json2.dotnet.cs
Created June 15, 2021 00:01
Deserializing Json 2 .net object.
//2 Scenarios. Either returning a list of json objects you can deserailze to .net objects
// OR returning a single json object, but the first property of the object is a list, and inside the list is the value you actually want.
HttpResponseMessage response = await client.GetAsync(targeturl);
response = await client.GetAsync(finalRequestUri);
var content = response.Content;
// ... Read the string.
string json = await content.ReadAsStringAsync();
JObject rss = JObject.Parse(json);
//1st scenario; i am returning an array of json objects, that will later be desearilzed.
@regisdiogo
regisdiogo / Startup.cs
Last active May 5, 2025 09:51
ASP.NET Core - Json serializer settings Enum as string and ignore null values
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
});
}
@bryanbarnard
bryanbarnard / SimpleHttpClient.cs
Created December 23, 2013 19:15
Simple C# .NET 4.5 HTTPClient Request Using Basic Auth and Proxy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;
namespace HTTP_Test