Skip to content

Commit

Permalink
make unjson not form multidimensional arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Nov 11, 2024
1 parent fcc5975 commit c05946d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Uiua is not yet stable.
## 0.14.0 - 202?-??-??
This version is not yet released. If you are reading this on the website, then these changes are live here.
### Language
- **Breaking Change**: [`un °`](https://uiua.org/docs/un) [`json`](https://uiua.org/docs/language/json) no longer attempts to form multidimensional arrays
- This makes deserializing JSON more consistent
- Add experimental inline macros
- Remove the previously deprecated experimental `coordinate ⟔` function
- Remove the previously deprecated experimental `struct` modifier
Expand All @@ -14,7 +16,7 @@ This version is not yet released. If you are reading this on the website, then t
- This massively simplifies compilation as well as optimizations and the derivation of inverses
- This should not affect any language semantics
- Improve pattern matching error messages
- Optimize the pattern `ⁿ%:1`
- Optimize the "root" pattern `ⁿ%:1`
### Website
- Add a new pad setting to show line values to the right of the code

Expand Down
8 changes: 5 additions & 3 deletions src/algorithm/monadic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1875,9 +1875,11 @@ impl Value {
}
rows.push(value);
}
if rows.windows(2).all(|win| {
win[0].shape() == win[1].shape() && win[0].type_name() == win[1].type_name()
}) {
if rows.iter().all(|val| val.shape().is_empty())
&& rows
.windows(2)
.all(|win| win[0].type_id() == win[1].type_id())
{
Value::from_row_values_infallible(rows)
} else {
Array::from(
Expand Down
3 changes: 3 additions & 0 deletions src/primitive/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3232,6 +3232,9 @@ primitive!(
/// While the number literals `0` and `1` are converted to their number equivalents in JSON, the shadowable constants `True` and `False` are converted to JSON `true` and `false`.
/// ex: json {0 1 2 3 True False}
///
/// [un][json] will never form multidimensional arrays, as the shape data is lost.
/// ex: °json json [1_2_3 4_5_6]
///
/// While [json] always produces ECMA-compliant JSON, [un][json] can parse [JSON5](https://json5.org/).
/// This means that you can use single quotes, unquoted keys, trailing commas, and comments.
/// ex: °json $ {foo: 'bar', /* cool */ baz: [1, 2, 3,],}
Expand Down

0 comments on commit c05946d

Please sign in to comment.