D
D
Deka0072019-08-12 14:13:03
.NET
Deka007, 2019-08-12 14:13:03

How to add value to specific key of JSON file?

In general, such a problem. It is necessary that the data that I enter is added to the link.
I tried it in different ways and every time it turns out like this
5d5147b988152191628909.png
. And you need everything to be in one link like this:
5d51483c7549a126903693.png
Here is the code:

string[] rssLinks = Console.ReadLine().Split(new char[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
  JObject obj = new JObject(new JProperty("link", rssLinks ));
  string path = Environment.CurrentDirectory + @".\RSS_Settings.json";
   using (StreamWriter sw = new StreamWriter(path, true, System.Text.Encoding.Default))
   {
       sw.WriteLine(obj.ToString());
   }

What are some ideas? I tried to Deserialize RSS_Settings.json and append new links via StreaWriter, File.AppendAllText, but nothing changed...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2019-08-12
@Deka007

You need to initially read the file, deserialize it, and already in this object find your own linkand add new lines. Then save it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question