How do I insert statements inside Newtonsoft.JSON codes

How do I insert statements inside Newtonsoft.JSON codes



So basically I wanted to do:
json code,
statement,
when statement is true,some other json text
continuation of previous json code



This is currently my code and I'm looking a way to shorten it, any solutions?


if (textBox1.Text != "Enter Address")

if (textBox2.Text != "Enter Address")

//1+2+3 OK
if (textBox3.Text != "Enter Address")

var item = new Item

version = 1,
schema_version = 2,
id = textBox14.Text,
title = textBox7.Text,
title_localized = textBox18.Text,
artist = textBox6.Text,
artist_localized = textBox8.Text,
artist_source = textBox9.Text,
illustrator = textBox10.Text,
illustrator_source = textBox11.Text,
charter = textBox13.Text,
music = new ItemMusic
path = textBox4.Text
,
music_preview = new ItemMusicPreview

path = textBox5.Text
,
background = new ItemBackground

path = open3.SafeFileName
,
charts = new List<ItemChart>

new ItemChart

type = "easy",
name = textBox15.Text,
difficulty = Convert.ToInt32(numericUpDown1.Value),
path = textBox1.Text
,
new ItemChart

type = "hard",
name = textBox16.Text,
difficulty = Convert.ToInt32(numericUpDown2.Value),
path = textBox2.Text
,
new ItemChart

type = "extreme",
name = textBox17.Text,
difficulty = Convert.ToInt32(numericUpDown3.Value),
path = textBox3.Text


;

var settings = new JsonSerializerSettings()

ContractResolver = new DefaultContractResolver

NamingStrategy = new SnakeCaseNamingStrategy()

;
var json = JsonConvert.SerializeObject(item, settings);
if (File.Exists(@"C:UsersPublicDesktoplevel files") == false)

// Make a path
System.IO.Directory.CreateDirectory(@"C:UsersPublicDesktoplevel files");

if (File.Exists($@"C:UsersPublicDesktoplevel filestextBox14.Text") == false)

// Make a path
System.IO.Directory.CreateDirectory($@"C:UsersPublicDesktoplevel filestextBox14.Text");

File.WriteAllText($@"C:UsersPublicDesktoplevel filestextBox14.Textlevel.json", json, new UTF8Encoding(false));

//1+2 (3) OK
else

var item = new Item

version = 1,
schema_version = 2,
id = textBox14.Text,
title = textBox7.Text,
title_localized = textBox18.Text,
artist = textBox6.Text,
artist_localized = textBox8.Text,
artist_source = textBox9.Text,
illustrator = textBox10.Text,
illustrator_source = textBox11.Text,
charter = textBox13.Text,
music = new ItemMusic

path = textBox4.Text
,
music_preview = new ItemMusicPreview

path = textBox5.Text
,
background = new ItemBackground

path = open3.SafeFileName
,
charts = new List<ItemChart>

new ItemChart

type = "easy",
name = textBox15.Text,
difficulty = Convert.ToInt32(numericUpDown1.Value),
path = textBox1.Text
,
new ItemChart

type = "hard",
name = textBox16.Text,
difficulty = Convert.ToInt32(numericUpDown2.Value),
path = textBox2.Text


;

var settings = new JsonSerializerSettings()

ContractResolver = new DefaultContractResolver

NamingStrategy = new SnakeCaseNamingStrategy()

;
var json = JsonConvert.SerializeObject(item, settings);
if (File.Exists(@"C:UsersPublicDesktoplevel files") == false)

// Make a path
System.IO.Directory.CreateDirectory(@"C:UsersPublicDesktoplevel files");

if (File.Exists($@"C:UsersPublicDesktoplevel filestextBox14.Text") == false)

// Make a path
System.IO.Directory.CreateDirectory($@"C:UsersPublicDesktoplevel filestextBox14.Text");

File.WriteAllText($@"C:UsersPublicDesktoplevel filestextBox14.Textlevel.json", json, new UTF8Encoding(false));


else

//1+3 (2) OK
if (textBox3.Text != "Enter Address")

var item = new Item

version = 1,
schema_version = 2,
id = textBox14.Text,
title = textBox7.Text,
title_localized = textBox18.Text,
artist = textBox6.Text,
artist_localized = textBox8.Text,
artist_source = textBox9.Text,
illustrator = textBox10.Text,
illustrator_source = textBox11.Text,
charter = textBox13.Text,
music = new ItemMusic

path = textBox4.Text
,
music_preview = new ItemMusicPreview

path = textBox5.Text
,
background = new ItemBackground

path = open3.SafeFileName
,
charts = new List<ItemChart>

new ItemChart

type = "easy",
name = textBox15.Text,
difficulty = Convert.ToInt32(numericUpDown1.Value),
path = textBox1.Text
,
new ItemChart

type = "extreme",
name = textBox17.Text,
difficulty = Convert.ToInt32(numericUpDown3.Value),
path = textBox3.Text


;

var settings = new JsonSerializerSettings()

ContractResolver = new DefaultContractResolver

NamingStrategy = new SnakeCaseNamingStrategy()

;
var json = JsonConvert.SerializeObject(item, settings);
if (File.Exists(@"C:UsersPublicDesktoplevel files") == false)

// Make a path
System.IO.Directory.CreateDirectory(@"C:UsersPublicDesktoplevel files");

if (File.Exists($@"C:UsersPublicDesktoplevel filestextBox14.Text") == false)

// Make a path
System.IO.Directory.CreateDirectory($@"C:UsersPublicDesktoplevel filestextBox14.Text");

File.WriteAllText($@"C:UsersPublicDesktoplevel filestextBox14.Textlevel.json", json, new UTF8Encoding(false));

//1 (2)(3) OK
else

var item = new Item

version = 1,
schema_version = 2,
id = textBox14.Text,
title = textBox7.Text,
title_localized = textBox18.Text,
artist = textBox6.Text,
artist_localized = textBox8.Text,
artist_source = textBox9.Text,
illustrator = textBox10.Text,
illustrator_source = textBox11.Text,
charter = textBox13.Text,
music = new ItemMusic

path = textBox4.Text
,
music_preview = new ItemMusicPreview

path = textBox5.Text
,
background = new ItemBackground

path = open3.SafeFileName
,
charts = new List<ItemChart>

new ItemChart

type = "easy",
name = textBox15.Text,
difficulty = Convert.ToInt32(numericUpDown1.Value),
path = textBox1.Text


;

var settings = new JsonSerializerSettings()

ContractResolver = new DefaultContractResolver

NamingStrategy = new SnakeCaseNamingStrategy()

;
var json = JsonConvert.SerializeObject(item, settings);
if (File.Exists(@"C:UsersPublicDesktoplevel files") == false)

// Make a path
System.IO.Directory.CreateDirectory(@"C:UsersPublicDesktoplevel files");

if (File.Exists($@"C:UsersPublicDesktoplevel filestextBox14.Text") == false)

// Make a path
System.IO.Directory.CreateDirectory($@"C:UsersPublicDesktoplevel filestextBox14.Text");

File.WriteAllText($@"C:UsersPublicDesktoplevel filestextBox14.Textlevel.json", json, new UTF8Encoding(false));



else
if (textBox2.Text != "Enter Address")

//2+3 (1) OK
if (textBox3.Text != "Enter Address")

var item = new Item

version = 1,
schema_version = 2,
id = textBox14.Text,
title = textBox7.Text,
title_localized = textBox18.Text,
artist = textBox6.Text,
artist_localized = textBox8.Text,
artist_source = textBox9.Text,
illustrator = textBox10.Text,
illustrator_source = textBox11.Text,
charter = textBox13.Text,
music = new ItemMusic

path = textBox4.Text
,
music_preview = new ItemMusicPreview

path = textBox5.Text
,
background = new ItemBackground

path = open3.SafeFileName
,
charts = new List<ItemChart>

new ItemChart

type = "hard",
name = textBox16.Text,
difficulty = Convert.ToInt32(numericUpDown2.Value),
path = textBox2.Text
,
new ItemChart

type = "extreme",
name = textBox17.Text,
difficulty = Convert.ToInt32(numericUpDown3.Value),
path = textBox3.Text


;

var settings = new JsonSerializerSettings()

ContractResolver = new DefaultContractResolver

NamingStrategy = new SnakeCaseNamingStrategy()

;
var json = JsonConvert.SerializeObject(item, settings);
if (File.Exists(@"C:UsersPublicDesktoplevel files") == false)

// Make a path
System.IO.Directory.CreateDirectory(@"C:UsersPublicDesktoplevel files");

if (File.Exists($@"C:UsersPublicDesktoplevel filestextBox14.Text") == false)

// Make a path
System.IO.Directory.CreateDirectory($@"C:UsersPublicDesktoplevel filestextBox14.Text");

File.WriteAllText($@"C:UsersPublicDesktoplevel filestextBox14.Textlevel.json", json, new UTF8Encoding(false));

//2 (1)(3)
else

var item = new Item

version = 1,
schema_version = 2,
id = textBox14.Text,
title = textBox7.Text,
title_localized = textBox18.Text,
artist = textBox6.Text,
artist_localized = textBox8.Text,
artist_source = textBox9.Text,
illustrator = textBox10.Text,
illustrator_source = textBox11.Text,
charter = textBox13.Text,
music = new ItemMusic

path = textBox4.Text
,
music_preview = new ItemMusicPreview

path = textBox5.Text
,
background = new ItemBackground

path = open3.SafeFileName
,
charts = new List<ItemChart>

new ItemChart

type = "hard",
name = textBox16.Text,
difficulty = Convert.ToInt32(numericUpDown2.Value),
path = textBox2.Text


;

var settings = new JsonSerializerSettings()

ContractResolver = new DefaultContractResolver

NamingStrategy = new SnakeCaseNamingStrategy()

;
var json = JsonConvert.SerializeObject(item, settings);
if (File.Exists(@"C:UsersPublicDesktoplevel files") == false)

// Make a path
System.IO.Directory.CreateDirectory(@"C:UsersPublicDesktoplevel files");

if (File.Exists($@"C:UsersPublicDesktoplevel filestextBox14.Text") == false)

// Make a path
System.IO.Directory.CreateDirectory($@"C:UsersPublicDesktoplevel filestextBox14.Text");

File.WriteAllText($@"C:UsersPublicDesktoplevel filestextBox14.Textlevel.json", json, new UTF8Encoding(false));


else

var item = new Item

version = 1,
schema_version = 2,
id = textBox14.Text,
title = textBox7.Text,
title_localized = textBox18.Text,
artist = textBox6.Text,
artist_localized = textBox8.Text,
artist_source = textBox9.Text,
illustrator = textBox10.Text,
illustrator_source = textBox11.Text,
charter = textBox13.Text,
music = new ItemMusic

path = textBox4.Text
,
music_preview = new ItemMusicPreview

path = textBox5.Text
,
background = new ItemBackground

path = open3.SafeFileName
,
charts = new List<ItemChart>

new ItemChart

type = "extreme",
name = textBox17.Text,
difficulty = Convert.ToInt32(numericUpDown3.Value),
path = textBox3.Text
,

;

var settings = new JsonSerializerSettings()

ContractResolver = new DefaultContractResolver

NamingStrategy = new SnakeCaseNamingStrategy()

;
var json = JsonConvert.SerializeObject(item, settings);
if (File.Exists(@"C:UsersPublicDesktoplevel files") == false)

// Make a path
System.IO.Directory.CreateDirectory(@"C:UsersPublicDesktoplevel files");

if (File.Exists($@"C:UsersPublicDesktoplevel filestextBox14.Text") == false)

// Make a path
System.IO.Directory.CreateDirectory($@"C:UsersPublicDesktoplevel filestextBox14.Text");

File.WriteAllText($@"C:UsersPublicDesktoplevel filestextBox14.Textlevel.json", json, new UTF8Encoding(false));



I was going to add "storyboard = open9.FileName" to "new ItemChart"s but not add the storyboard line when the file address is not imported.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ