Helper function to count array dimensions
(value: &JsonValue)
| 776 | |
| 777 | /// Helper function to count array dimensions |
| 778 | fn count_dimensions(value: &JsonValue) -> i32 { |
| 779 | match value { |
| 780 | JsonValue::Array(arr) => { |
| 781 | if arr.is_empty() { |
| 782 | 1 |
| 783 | } else { |
| 784 | // Check if any element is an array |
| 785 | let max_sub_dimensions = arr.iter() |
| 786 | .filter_map(|v| { |
| 787 | if matches!(v, JsonValue::Array(_)) { |
| 788 | Some(count_dimensions(v)) |
| 789 | } else { |
| 790 | None |
| 791 | } |
| 792 | }) |
| 793 | .max() |
| 794 | .unwrap_or(0); |
| 795 | |
| 796 | if max_sub_dimensions > 0 { |
| 797 | 1 + max_sub_dimensions |
| 798 | } else { |
| 799 | 1 |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | _ => 0, |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | |
| 808 |
no test coverage detected