Skip to content

Commit

Permalink
Updated code formatting to match rules in .editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jun 8, 2024
1 parent 59d78cb commit 86ef63c
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/Hyperbee.Json/JsonPathBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,43 +97,43 @@ private static string BuildPath( int elementId, Dictionary<int, (int parentId, s
return string.Join( string.Empty, pathSegments );
}

/*
public string GetPath( JsonElement targetElement )
{
var stack = new Stack<(JsonElement element, string path)>( 4 );
stack.Push( (_rootElement, "$") );
while ( stack.Count > 0 )
/*
public string GetPath( JsonElement targetElement )
{
var (currentElement, currentPath) = stack.Pop();
if ( _comparer.Equals( currentElement, targetElement ) )
return currentPath;
var stack = new Stack<(JsonElement element, string path)>( 4 );
stack.Push( (_rootElement, "$") );
switch ( currentElement.ValueKind )
while ( stack.Count > 0 )
{
case JsonValueKind.Object:
foreach ( var property in currentElement.EnumerateObject() )
{
var newPath = $"{currentPath}.{property.Name}";
stack.Push( (property.Value, newPath) );
}
break;
case JsonValueKind.Array:
var index = 0;
foreach ( var element in currentElement.EnumerateArray() )
{
var newPath = $"{currentPath}[{index++}]";
stack.Push( (element, newPath) );
}
break;
var (currentElement, currentPath) = stack.Pop();
if ( _comparer.Equals( currentElement, targetElement ) )
return currentPath;
switch ( currentElement.ValueKind )
{
case JsonValueKind.Object:
foreach ( var property in currentElement.EnumerateObject() )
{
var newPath = $"{currentPath}.{property.Name}";
stack.Push( (property.Value, newPath) );
}
break;
case JsonValueKind.Array:
var index = 0;
foreach ( var element in currentElement.EnumerateArray() )
{
var newPath = $"{currentPath}[{index++}]";
stack.Push( (element, newPath) );
}
break;
}
}
}
return null;
}
*/
return null;
}
*/
}

0 comments on commit 86ef63c

Please sign in to comment.