Skip to content

Commit afe6714

Browse files
committed
Fix parsing of complex json, containing closing array or object in string
1 parent 5174638 commit afe6714

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ egui_extras = { version = "0.29.1", default-features = false, features = ["svg"]
1717
#egui = { path = "C:\\dev\\egui\\crates\\egui"}
1818
#eframe = { path = "C:\\dev\\egui\\crates\\eframe"}
1919
#egui_extras = { path = "C:\\dev\\egui\\crates\\egui_extras"}
20-
json-flat-parser = {git = "https://github.com/nmeylan/json-parser-flat-format.git", rev = "4604c8e99ed2d11b345e55317d47ff83b1f1fc9e", features = ["indexmap", "simdutf8", "serde"]}
20+
json-flat-parser = {git = "https://github.com/nmeylan/json-parser-flat-format.git", rev = "c2503441dcd1ee98a9839d30534f151b9948b9b2", features = ["indexmap", "simdutf8", "serde"]}
2121
rayon = {version = "1.10.0"}
2222
rfd = {version = "0.14.1"}
2323
indexmap = "2.2.6"

src/compatibility.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::time::Instant;
1+
use std::time::{Duration,Instant};
22
#[macro_export]
33
macro_rules! log {
44
() => {

src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,6 @@ impl MyApp<'_> {
237237
fn open_json_content(&mut self, max_depth: u8, json: &[u8]) {
238238
let mut found_array = false;
239239
let size = json.len() / 1024 / 1024;
240-
log!(
241-
"open_json_content with size {}mb, found array {}",
242-
size,
243-
found_array
244-
);
245240
for byte in json {
246241
if *byte == b'[' {
247242
found_array = true;
@@ -251,6 +246,11 @@ impl MyApp<'_> {
251246
break;
252247
}
253248
}
249+
log!(
250+
"open_json_content with size {}mb, found array {}",
251+
size,
252+
found_array
253+
);
254254
if found_array || self.selected_pointer.is_some() {
255255
let start = crate::compatibility::now();
256256
let mut options = ParseOptions::default()
@@ -460,7 +460,7 @@ impl eframe::App for MyApp<'_> {
460460
if let Ok(event) = self.async_events_channel.1.try_recv() {
461461
self.force_repaint = false;
462462
match event {
463-
AsyncEvent::LoadJson(_json_bytes) => {
463+
AsyncEvent::LoadJson(json_bytes) => {
464464
#[cfg(target_arch = "wasm32")]
465465
{
466466
self.web_loaded_json = Some(json_bytes);
@@ -738,7 +738,7 @@ impl eframe::App for MyApp<'_> {
738738
let max_rect = ui.max_rect();
739739
let mut rect = ui.max_rect();
740740
rect.min.y = rect.max.y / 2.0 - 20.0;
741-
let already_interact = false;
741+
let mut already_interact = false;
742742

743743
if !already_interact {
744744
let response = ui.interact(max_rect, Id::new("select_file"), Sense::click());

web/json-editor.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,19 +1649,19 @@ let wasm_bindgen;
16491649
const ret = makeMutClosure(arg0, arg1, 210, __wbg_adapter_32);
16501650
return ret;
16511651
};
1652-
imports.wbg.__wbindgen_closure_wrapper1516 = function(arg0, arg1, arg2) {
1652+
imports.wbg.__wbindgen_closure_wrapper1517 = function(arg0, arg1, arg2) {
16531653
const ret = makeMutClosure(arg0, arg1, 393, __wbg_adapter_35);
16541654
return ret;
16551655
};
1656-
imports.wbg.__wbindgen_closure_wrapper1518 = function(arg0, arg1, arg2) {
1656+
imports.wbg.__wbindgen_closure_wrapper1519 = function(arg0, arg1, arg2) {
16571657
const ret = makeMutClosure(arg0, arg1, 393, __wbg_adapter_35);
16581658
return ret;
16591659
};
1660-
imports.wbg.__wbindgen_closure_wrapper1520 = function(arg0, arg1, arg2) {
1660+
imports.wbg.__wbindgen_closure_wrapper1521 = function(arg0, arg1, arg2) {
16611661
const ret = makeMutClosure(arg0, arg1, 393, __wbg_adapter_40);
16621662
return ret;
16631663
};
1664-
imports.wbg.__wbindgen_closure_wrapper1932 = function(arg0, arg1, arg2) {
1664+
imports.wbg.__wbindgen_closure_wrapper1933 = function(arg0, arg1, arg2) {
16651665
const ret = makeMutClosure(arg0, arg1, 441, __wbg_adapter_43);
16661666
return ret;
16671667
};

web/json-editor_bg.wasm

-435 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)