mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-16 21:24:43 +00:00
Updates to json2.4.1 to resolve issues with reading nested array objects
This commit is contained in:
@@ -12,7 +12,6 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
{
|
||||
public string SearchPropertyName { get; set; }
|
||||
public string SearchPropertyValue { get; set; }
|
||||
public string AppendToPathPrefix { get; set; }
|
||||
|
||||
int ArrayIndex;
|
||||
|
||||
@@ -47,10 +46,11 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
public void InitializeWithAppend(string file, string key, string pathPrefix, string pathAppend,
|
||||
string pathSuffix, string searchPropertyName, string searchPropertyValue)
|
||||
{
|
||||
base.Initialize(file, key, pathPrefix, pathSuffix);
|
||||
string pathPrefixWithAppend = (pathPrefix != null ? pathPrefix : "") + GetPathAppend(pathAppend);
|
||||
base.Initialize(file, key, pathPrefixWithAppend, pathSuffix);
|
||||
|
||||
SearchPropertyName = searchPropertyName;
|
||||
SearchPropertyValue = searchPropertyValue;
|
||||
AppendToPathPrefix = pathAppend;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,10 +63,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
/// <returns></returns>
|
||||
protected override string GetFullPath(string path)
|
||||
{
|
||||
return string.Format("{0}[{1}]{2}.{3}{4}",
|
||||
return string.Format("{0}[{1}].{2}{3}",
|
||||
PathPrefix == null ? "" : PathPrefix,
|
||||
ArrayIndex,
|
||||
GetPathAppend(),
|
||||
path,
|
||||
PathSuffix == null ? "" : PathSuffix);
|
||||
}
|
||||
@@ -81,9 +80,8 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
/// Provides the path append for GetFullPath
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GetPathAppend()
|
||||
string GetPathAppend(string a)
|
||||
{
|
||||
var a = AppendToPathPrefix;
|
||||
if (string.IsNullOrEmpty(a))
|
||||
{
|
||||
return "";
|
||||
@@ -111,6 +109,7 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
if (PathPrefix == null)
|
||||
throw new InvalidOperationException("Cannot do operations before PathPrefix is set");
|
||||
|
||||
|
||||
var token = Master.JsonObject.SelectToken(PathPrefix);
|
||||
if (token is JArray)
|
||||
{
|
||||
@@ -133,7 +132,7 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
|
||||
this.LinkedToObject = true;
|
||||
ArrayIndex = array.IndexOf(item);
|
||||
OnStringChange(GetFullPath(""), 0, JsonToSimplConstants.FullPathToArrayChange);
|
||||
OnStringChange(string.Format("{0}[{1}]", PathPrefix, ArrayIndex), 0, JsonToSimplConstants.FullPathToArrayChange);
|
||||
Debug.Console(1, "JSON Child[{0}] Found array match at index {1}", Key, ArrayIndex);
|
||||
return true;
|
||||
}
|
||||
@@ -144,7 +143,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, "JSON Child[{0}] Path '{1}' is not an array", Key, PathPrefix);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
protected virtual string GetFullPath(string path)
|
||||
{
|
||||
return (PathPrefix != null ? PathPrefix : "") +
|
||||
path + (PathSuffix != null ? PathSuffix : "");
|
||||
path + (PathSuffix != null ? PathSuffix : "");
|
||||
}
|
||||
|
||||
// Helpers for events
|
||||
|
||||
Reference in New Issue
Block a user