I have generated two text file and jpeg file from wikipedia. Now I want to serialize all this file in a json format. 1st I generated a short text file, 2nd I generated Latitude and longitude for that location and third is image file as hash code. Image and shorttext file is working perfectly. But I am having problem with latitude and longitude file. My text file is look like this with new line
Lat:54.33333333
Lon:10.13333333
I want to get this in an array. Now My json class which I am using to create json for all object is -
public class GeoCoordinates
{
public double Longitude { get; set; }
public double Latitude { get; set; }
}
public class POIData
{
public string ShortText { get; set; }
public GeoCoordinates GeoCoordinates { get; set; }
public List<string> Images { get; set; }
public string ToJson()
{
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
return json;
}
public void FromJson(string json)
{
dynamic poi = JsonConvert.DeserializeObject<POIData>(json);
ShortText = poi.ShortText;
Images = poi.Images;
GeoCoordinates = poi.GeoCordinates;
}
// This method will create json file for Neuschwanstein_Castle
public void ToJsonForLocation(string name)
{
var startPath = Application.StartupPath;
string folderName = Path.Combine(startPath, "Text_ImageWithHash");
System.IO.Directory.CreateDirectory(folderName);
string fileName = name + ".json";
var path = Path.Combine(folderName, fileName);
var Jpeg_File = new DirectoryInfo(startPath + @"\Image\" + name).GetFiles("*.jpg");
this.ShortText = File.ReadAllText(startPath + @"\Short Text\" + name+".json");
this.GeoCoordinates = File.ReadAllLines(startPath + @"\Latitude Longitude\" + name + ".json");
this.Images = new List<string> { Jpeg_File[0].Name, Jpeg_File[1].Name };
string json = ToJson();
File.WriteAllText(path, json);
}
}
I am trying to get geocordinate in an array.But not working at all.
my json file look like this
[
{
"ShortText": "Kiel is the capital and most &tldr; from the wedge form of its bay ",
"GeoCordinates": null,
"Images": [
"9B9C2047.jpg",
"CAD72F59.jpg"
]
}
]