I’ve been working on a web application for an agri-technology company here in Kansas. I’ve been away from web application development for a long time, and this project has been built using .NET. I’ve never made a web application in .NET.
I’ve made some desktop applications in C# using .NET and Visual Studio, which made me think I could assist with this project. But, I’ve never dove into an existing project like this and tried to make useful modifications to it. So this is another first for me.
Today I built a piece of code that I think will be useful for solving one of the problems on my to-do list. It is a console app that reads a specialized JSON file, a GeoJSON actually, and converts it to a CSV file. When I started looking at solving this issue, I thought it would be a matter of reading a JSON text file, parsing it, and re-writing it out in the new CSV format. Well, it’s a lot more complicated than it sounds.
I wound up using a couple of data structures in C# I was familiar with, a List and a DataTable. I suspect if I was smarter, or found the right example, I might have been able to do it with only one of these. But alas, I have been hacking away at this issue for some time now. Anyway, for now it goes from .GeoJSON -> List -> DataTable -> CSV. I thought I could go directly to the DataTable, but because GeoJSON is JSON data within JSON, my attempt to skip the List caused a problem.
It’s a lot of shuffling of data, not very elegant, but it works. Now I’m going to see if I can optimize things a bit, and integrate it into the bigger application.