Build a json editor program

amir1384am

New member
Joined
May 20, 2022
Messages
3
Programming Experience
1-3
Hi, I need help. I want to create a program with c # that edits a json file that has four lines. For example, there are four textBoxes, each of which edits the information of one line.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,251
Location
Chesapeake, VA
Programming Experience
10+
Is there something significant about each of those 4 lines? If not, then just use one multiline textbox.
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
4,466
Location
Sydney, Australia
Programming Experience
10+
So what's the actual problem? If you want to create an application with four TextBoxes then go ahead. If and when you encounter an actual issue, feel free to provide an explanation of that actual issue. We can then help you with that specifically.
 

amir1384am

New member
Joined
May 20, 2022
Messages
3
Programming Experience
1-3
Is there something significant about each of those 4 lines? If not, then just use one multiline textbox.
Picsart_22-05-21_07-32-25-728.jpg
I sent the sample look inside this photo. I want the program to be such that if that line writes something, it should also write inside this json.
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
4,466
Location
Sydney, Australia
Programming Experience
10+
Again, what's the actual problem? This is not a code-writing service so you don't just come and tell us what you want and we do it for you. There's plenty of information out there about writing JSON in C#. If that's what you want to do, do some research on that subject. Once you know what to do, do it. If there's something specific that you don't understand or what you try does work then we can help you with that specifically. If you just want us to do it for you so you don't have to make that effort then you'll be disappointed. We're here to help but "help" implies you doing your share, not us doing it all for you.
 

amir1384am

New member
Joined
May 20, 2022
Messages
3
Programming Experience
1-3
Again, what's the actual problem? This is not a code-writing service so you don't just come and tell us what you want and we do it for you. There's plenty of information out there about writing JSON in C#. If that's what you want to do, do some research on that subject. Once you know what to do, do it. If there's something specific that you don't understand or what you try does work then we can help you with that specifically. If you just want us to do it for you so you don't have to make that effort then you'll be disappointed. We're here to help but "help" implies you doing your share, not us doing it all for you.
Actually I do not know how to put textBox text in json
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
4,466
Location
Sydney, Australia
Programming Experience
10+
The TextBox is irrelevant. A TextBox is simply a means for the user to edit a string. That string is the same as any other, so any information on how to write a string to JSON is relevant and there's plenty of such information about. Your determination to do nothing for yourself is admirable but ultimately futile. Open your favourite search engine and make an effort to learn how to write JSON data in C#. Once you have learned what to do, do it. As I have already said, if you do that and there is something that you don't understand or what you do doesn't work as expected, THEN you have a problem that we can help you with. Until you've actually tried something, you don't know that you can't do it and if you don't know that you can't do it yourself then you don't need us to do it for you.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,251
Location
Chesapeake, VA
Programming Experience
10+
Actually I do not know how to put textBox text in json
The issue seems to be that you want to edit JSON, when what you really need to do is just write or generate JSON. Trying to insert text into an existing file is a hard problem to solve. Trying to just create a file is much easier.
 

ProtekNickz

Member
Joined
Jan 13, 2022
Messages
14
Programming Experience
5-10
Hi, I need help. I want to create a program with c # that edits a json file that has four lines. For example, there are four textBoxes, each of which edits the information of one line.
Hi, I see every one here has answered you, but I'm going to try elaborate a bit,

Serialize:
using System.Text.Json;

static string _json = File.ReadAllText($@"{Application.StartupPath}\{_MyPath}");
        _RulesRoot _cont = JsonSerializer.Deserialize<_RulesRoot>(_json);

        public class _RulesSettings
        {
            public string _Game { get; set; }
            public string _Country { get; set; }
            public string _Address { get; set; }
        }

        public class _RulesRoot
        {
            public List<_RulesSettings> _Rules { get; set; }
        }

as you can see this is code from my own project, it's not all of it, just as a guidance, you will need to Import a reference to Json library then add it to the top "using System.Text.Json;" less the quotes, This will only Read in the values, which are mine at the moment, but I'm sure with more reading on MSDN or else where you can get to grips easily.

Hope this help you on your journey!

ProtekNickz :)
 
Top Bottom