Last active
July 8, 2020 11:41
-
-
Save blubbll/f17d9574fae84a914b7089db897b9e8f to your computer and use it in GitHub Desktop.
parsing scanned netlist in c#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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