I am creating an app that gets information and download movies from a site. I have succeeded in setting the information in different arrays and combining them together to 1 array.
However, now I am trying to put that array inside a bigger array (want to work with JSON), and that is failing.
My current Json output looks like this:
{"moviedata":
["http:/xxxx","title title ","k0X0HrYtMm5u"],"tags":
["x","x","x","Prop","x","x","x","x","x","x","x"],"categorydata":
["x","x","x"]}
Which is achieved with this code:
Dictionary<string, string[]> movie = new Dictionary<string, string[]>();
moviedata.Add("moviedata", moviegenerala);
moviedata.Add("tags", tagsa);
moviedata.Add("categorydata", categoriesa);
string moviejson = JsonConvert.SerializeObject(moviedata);
I want to add another layer on top of this, so there is a general tab named "Movie", and for each movie it has this information. How would I do that?
UPDATE: Added this code:
var myShape = new
{
Movie = new Dictionary<string, string[]>
{
["moviedata"] = moviegenerala,
["tags"] = tagsa,
["categorydata"] = categoriesa,
["localdata"] = localdataa
}
};
var moviejson = JsonConvert.SerializeObject(myShape);
The JSON seems to be correct, but it cannot parse, after the first listing it says there is text after the closing bracket.
UPDATE: Changed code to this:
Dictionary<string, string[]> movies = new Dictionary<string, string[]>();
var myShape = movies.Select(m => new
{
Movie = new Dictionary<string, string[]>
{
// TODO - you'll need to get the appropriate data for this movie
["moviedata"] = moviegenerala,
["tags"] = tagsa,
["categorydata"] = categoriesa,
["localdata"] = localdataa
}
});
var moviejson = JsonConvert.SerializeObject(myShape);
File.AppendAllText("moviedata.txt", moviejson);
But now it only gives empty brackets :(