mirror of
https://github.com/4sval/FModel.git
synced 2026-04-21 09:07:45 -05:00
Added ConvertJson2Token utility.
This commit is contained in:
parent
98efb71cc6
commit
63925c1df2
|
|
@ -1,4 +1,4 @@
|
|||
using FModel.Methods.SyntaxHighlighter;
|
||||
using FModel.Methods.SyntaxHighlighter;
|
||||
using FModel.Methods.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
|
@ -206,23 +206,8 @@ namespace FModel.Methods.Assets
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetMainToken = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null && AssetMainToken["export_type"] != null && AssetMainToken["properties"] != null)
|
||||
{
|
||||
ExportType = AssetMainToken["export_type"].Value<string>();
|
||||
|
|
|
|||
|
|
@ -55,18 +55,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray AssetProperties = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
@ -236,18 +225,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetRewarsTableData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetRewarsTableMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetRewarsTableData);
|
||||
AssetRewarsTableMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetRewarsTableMainToken = AssetRewarsTableData;
|
||||
}
|
||||
|
||||
JToken AssetRewarsTableMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetRewarsTableMainToken != null)
|
||||
{
|
||||
JArray propertiesArray = AssetRewarsTableMainToken["rows"].Value<JArray>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FModel.Methods.Utilities;
|
||||
using FModel.Methods.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PakReader;
|
||||
|
|
@ -71,18 +71,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray propertiesArray = AssetMainToken["rows"].Value<JArray>();
|
||||
|
|
@ -146,18 +135,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray propertiesArray = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
@ -219,18 +197,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray AssetProperties = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FModel.Methods.Utilities;
|
||||
using FModel.Methods.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PakReader;
|
||||
|
|
@ -34,18 +34,7 @@ namespace FModel.Methods.Assets.IconCreator.HeroID
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray heroGameplayProperties = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
@ -144,18 +133,7 @@ namespace FModel.Methods.Assets.IconCreator.HeroID
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray abilityKitProperties = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FModel.Methods.Utilities;
|
||||
using FModel.Methods.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PakReader;
|
||||
|
|
@ -78,18 +78,7 @@ namespace FModel.Methods.Assets.IconCreator
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray AssetProperties = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
@ -164,18 +153,7 @@ namespace FModel.Methods.Assets.IconCreator
|
|||
{
|
||||
FWindow.FCurrentAsset = Path.GetFileName(displayAssetPath);
|
||||
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray displayAssetProperties = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
@ -254,18 +232,7 @@ namespace FModel.Methods.Assets.IconCreator
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray renderSwitchProperties = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FModel.Methods.Utilities;
|
||||
using FModel.Methods.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PakReader;
|
||||
|
|
@ -163,18 +163,7 @@ namespace FModel.Methods.Assets.IconCreator
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray propertiesArray = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FModel.Methods.SyntaxHighlighter;
|
||||
using FModel.Methods.SyntaxHighlighter;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
|
@ -441,6 +441,23 @@ namespace FModel.Methods.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
public static JToken ConvertJson2Token(string json)
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(json);
|
||||
JToken AssetMainToken = null;
|
||||
if (json.StartsWith("[") && json.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (json.StartsWith("{") && json.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
return AssetMainToken;
|
||||
}
|
||||
|
||||
public static T GetPropertyTag<T>(JArray properties, string name)
|
||||
{
|
||||
return properties
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FModel.Methods.Assets.IconCreator.ChallengeID;
|
||||
using FModel.Methods.Assets.IconCreator.ChallengeID;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PakReader;
|
||||
|
|
@ -133,18 +133,7 @@ namespace FModel.Methods.Utilities
|
|||
|
||||
if (AssetsUtility.IsValidJson(jsonData))
|
||||
{
|
||||
dynamic AssetData = JsonConvert.DeserializeObject(jsonData);
|
||||
JToken AssetMainToken = null;
|
||||
if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
|
||||
{
|
||||
JArray AssetArray = JArray.FromObject(AssetData);
|
||||
AssetMainToken = AssetArray[0];
|
||||
}
|
||||
else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
|
||||
{
|
||||
AssetMainToken = AssetData;
|
||||
}
|
||||
|
||||
JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
|
||||
if (AssetMainToken != null)
|
||||
{
|
||||
JArray renderSwitchProperties = AssetMainToken["properties"].Value<JArray>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user