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