控制模版数据转换,将json字符串反序列化List<string>时,代码调整
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using JNPF.Common.Const;
|
||||
using System.Text.RegularExpressions;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos;
|
||||
using JNPF.Common.Extension;
|
||||
@@ -307,7 +308,18 @@ public class FormDataParsing : ITransient
|
||||
else conversionData = data;
|
||||
break;
|
||||
default:
|
||||
conversionData = data.ToString().ToObject<List<object>>();
|
||||
//modify by ly on 20230327
|
||||
var temp = data.ToString();
|
||||
Regex re = new Regex("(?<=\").*?(?=\")", RegexOptions.None);
|
||||
if (!re.IsMatch(temp))
|
||||
{
|
||||
temp = $"\"{data}\"";
|
||||
}
|
||||
if (!temp.StartsWith("[") && !temp.EndsWith("]"))
|
||||
{
|
||||
temp = $"[{temp}]";
|
||||
}
|
||||
conversionData = temp.ToObject<List<object>>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1443,6 +1455,7 @@ public class FormDataParsing : ITransient
|
||||
if (!(dataMap[strKey[i]] is null))
|
||||
{
|
||||
FieldsModel? form = formData.Where(f => f.__vModel__ == strKey[i]).FirstOrDefault();
|
||||
|
||||
if (form != null)
|
||||
{
|
||||
if (form.__vModel__.Contains(form.__config__.jnpfKey + "Field")) dataMap[strKey[i]] = TemplateControlsDataConversion(dataMap[strKey[i]], form);
|
||||
|
||||
Reference in New Issue
Block a user