diff --git a/Cargo.lock b/Cargo.lock index 40482af..4d21c83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1440,7 +1440,7 @@ dependencies = [ [[package]] name = "json-flat-parser" version = "0.1.0" -source = "git+https://github.com/nmeylan/json-parser-flat-format.git?rev=c652033#c6520332bc2545d04022c331211b16b313443e11" +source = "git+https://github.com/nmeylan/json-parser-flat-format.git?rev=1ba7441#1ba74417f208a10c05ec6e919932d87641eac3c3" dependencies = [ "indexmap", "serde", diff --git a/Cargo.toml b/Cargo.toml index 38ec413..02125b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ eframe = { version = "0.28.1", default-features = false, features = [ "x11"] } egui = { version = "0.28.1", default-features = false, features = [] } egui_extras = { version = "0.28.1", default-features = false, features = ["svg"] } -json-flat-parser = {git = "https://github.com/nmeylan/json-parser-flat-format.git", rev = "c652033", features = ["indexmap", "simdutf8", "serde"]} +json-flat-parser = {git = "https://github.com/nmeylan/json-parser-flat-format.git", rev = "1ba7441", features = ["indexmap", "simdutf8", "serde"]} rayon = {version = "1.10.0"} rfd = {version = "0.14.1"} indexmap = "2.2.6" diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 141936b..1fbb081 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -112,16 +112,26 @@ pub fn change_depth_array<'array>(previous_parse_result: ParseResult, mu Ok((mem::take(&mut new_json_array_guard), unique_keys, 4)) } pub fn as_array<'array>(mut previous_parse_result: ParseResult) -> Result<(Vec>, Vec>), String> { - if !matches!(previous_parse_result.json[0].pointer.value_type, ValueType::Array(_)) { + let (root_value, start_index, mut end_index) = if let Some(ref started_parsing_at) = previous_parse_result.started_parsing_at { + let mut root_value = previous_parse_result.json[previous_parse_result.started_parsing_at_index_start].clone(); + (root_value, previous_parse_result.started_parsing_at_index_start, previous_parse_result.started_parsing_at_index_end) + } else { + (previous_parse_result.json[0].clone(), 0, 0) + }; + + if !matches!(root_value.pointer.value_type, ValueType::Array(_)) { return Err("Parsed json root is not an array".to_string()); } - let root_array_len = match previous_parse_result.json[0].pointer.value_type { + let root_array_len = match root_value.pointer.value_type { ValueType::Array(root_array_len) => root_array_len, _ => panic!("") }; + if end_index == 0 { + end_index = previous_parse_result.json.len() - 1; + } let mut unique_keys: Vec = Vec::with_capacity(16); let mut res: Vec> = Vec::with_capacity(root_array_len); - let mut j = previous_parse_result.json.len() - 1; + let mut j = end_index; let estimated_capacity = 16; for i in (0..root_array_len).rev() { let mut flat_json_values: Vec> = Vec::with_capacity(estimated_capacity); @@ -190,7 +200,9 @@ pub fn as_array<'array>(mut previous_parse_result: ParseResult) -> Resul break; } } - res.push(JsonArrayEntries:: { entries: flat_json_values, index: i }); + if !flat_json_values.is_empty() { + res.push(JsonArrayEntries:: { entries: flat_json_values, index: i }); + } } res.reverse(); unique_keys.sort(); diff --git a/web/json-editor.js b/web/json-editor.js index 2f4aeba..daf4962 100644 --- a/web/json-editor.js +++ b/web/json-editor.js @@ -228,7 +228,7 @@ function makeMutClosure(arg0, arg1, dtor, f) { return real; } function __wbg_adapter_28(arg0, arg1) { - wasm.wasm_bindgen__convert__closures__invoke0_mut__h5f2f14d0e5bf9f7d(arg0, arg1); + wasm.wasm_bindgen__convert__closures__invoke0_mut__h2d5dad65975d3dc3(arg0, arg1); } function __wbg_adapter_31(arg0, arg1) { @@ -404,10 +404,6 @@ function __wbg_get_imports() { const ret = getStringFromWasm0(arg0, arg1); return addHeapObject(ret); }; - imports.wbg.__wbindgen_object_clone_ref = function(arg0) { - const ret = getObject(arg0); - return addHeapObject(ret); - }; imports.wbg.__wbindgen_cb_drop = function(arg0) { const obj = takeObject(arg0).original; if (obj.cnt-- == 1) { @@ -417,6 +413,10 @@ function __wbg_get_imports() { const ret = false; return ret; }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; imports.wbg.__wbindgen_string_get = function(arg0, arg1) { const obj = getObject(arg1); const ret = typeof(obj) === 'string' ? obj : undefined; @@ -1636,28 +1636,28 @@ function __wbg_get_imports() { const ret = wasm.memory; return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper818 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 197, __wbg_adapter_28); + imports.wbg.__wbindgen_closure_wrapper732 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 138, __wbg_adapter_28); return addHeapObject(ret); }; imports.wbg.__wbindgen_closure_wrapper985 = function(arg0, arg1, arg2) { const ret = makeMutClosure(arg0, arg1, 238, __wbg_adapter_31); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper1533 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 436, __wbg_adapter_34); + imports.wbg.__wbindgen_closure_wrapper1545 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 448, __wbg_adapter_34); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper1535 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 436, __wbg_adapter_37); + imports.wbg.__wbindgen_closure_wrapper1547 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 448, __wbg_adapter_37); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper1537 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 436, __wbg_adapter_37); + imports.wbg.__wbindgen_closure_wrapper1549 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 448, __wbg_adapter_37); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper1915 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 463, __wbg_adapter_42); + imports.wbg.__wbindgen_closure_wrapper1927 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 475, __wbg_adapter_42); return addHeapObject(ret); }; diff --git a/web/json-editor_bg.wasm b/web/json-editor_bg.wasm index 47e5edf..814de6f 100644 Binary files a/web/json-editor_bg.wasm and b/web/json-editor_bg.wasm differ