Skip to content

Instantly share code, notes, and snippets.

@blubbll
Last active July 8, 2020 11:41
Show Gist options
  • Save blubbll/f17d9574fae84a914b7089db897b9e8f to your computer and use it in GitHub Desktop.
Save blubbll/f17d9574fae84a914b7089db897b9e8f to your computer and use it in GitHub Desktop.
parsing scanned netlist in c#
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace parseNetlist
{
public class Entry
{
public int id { get; set; }
public string leaseTimeRemaining { get; set; }
public string MACAddress { get; set; }
public string hostName { get; set; }
public string IPAddress { get; set; }
}
internal class Program
{
private static void Main(string[] args)
{
var jsonPath = @"entries.json";
var oldJson = String.Empty;
var ignoreMacs = new List<string> { };
if (File.Exists(jsonPath))
{
try
{
var json = File.ReadAllText(jsonPath);
if (!json.Equals(oldJson))
{
var devices = JArray.Parse(json).ToObject<List<Entry>>();
foreach (var _device in devices)
{
var device = _device;
}
oldJson = json;
}
}
catch (Exception e)
{
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment