mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 10:58:11 +08:00
Migrate remaining node graph data types from Vec to Table (#4067)
* Move Vec<String> to Table<String> * Remove old VecDVec2 * Move Vec<u8> to Table<u8> * Move Vec<f64> to Table<f64> * Move [f64; 4] to Table<f64> * Move Vec<NodeId> to Table<NodeId> * Tidy up the TaggedValue variants * Move Vec<BrushStroke> to Table<BrushStroke> * Add missing type implementations * Fix tests ---------
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use core_types::Ctx;
|
||||
use core_types::table::{Table, TableRow};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::unescape_string;
|
||||
@@ -237,15 +238,15 @@ fn query_json_all(
|
||||
/// Strips the surrounding double quotes from string values, returning the raw text. Other types are never wrapped in quotes.
|
||||
#[default(true)]
|
||||
unquote_strings: bool,
|
||||
) -> Vec<String> {
|
||||
) -> Table<String> {
|
||||
let cleaned = strip_trailing_commas(&json);
|
||||
let Ok(value): Result<Value, _> = serde_json::from_str(&cleaned) else { return Vec::new() };
|
||||
let Some(segments) = parse_json_path(path.trim()) else { return Vec::new() };
|
||||
let Ok(value): Result<Value, _> = serde_json::from_str(&cleaned) else { return Table::new() };
|
||||
let Some(segments) = parse_json_path(path.trim()) else { return Table::new() };
|
||||
|
||||
let mut results = Vec::new();
|
||||
resolve_all(&value, &segments, !unquote_strings, &mut results);
|
||||
|
||||
results
|
||||
results.into_iter().map(TableRow::new_from_element).collect()
|
||||
}
|
||||
|
||||
/// A parsed segment of a JSON access path.
|
||||
|
||||
Reference in New Issue
Block a user