C
C#4mo ago
Neeko

Parts of string to special json format

Hi, I need to transform array of string to a special json format. I don't know where to start to achieve this.
c#
foreach (var word in words) {
Console.WriteLine($"word = {word}");

// word = string of characters like :

// hello
// hello world
// hello world test
// world
// w (alias of world)
// ...
}
c#
foreach (var word in words) {
Console.WriteLine($"word = {word}");

// word = string of characters like :

// hello
// hello world
// hello world test
// world
// w (alias of world)
// ...
}
And I need to transform to json like this :
{
"hello": {
"world": {
"_usage": "hello world",
"test": {
"_usage": "hello world test"
}
}
},
"world": {
"_alias": "w",
"_usage": "(w)orld"
},
// etc ...
}
{
"hello": {
"world": {
"_usage": "hello world",
"test": {
"_usage": "hello world test"
}
}
},
"world": {
"_alias": "w",
"_usage": "(w)orld"
},
// etc ...
}
Thanks for you help!
1 Reply
Angius
Angius4mo ago
1. Create an object (or multiple, in this case) that would represent your JSON 2. Instantiate them 3. Serialize them