Skip to content

AnimationExport fails with push! MethodError on JSON.jl v1.x #144

Closed

Description

@juguma

Exporting an animation to three.js JSON (Scene(..., animationFile="...")) fails with current JSON.jl v1.x (tested v1.7.1), despite Project.toml allows JSON = "1".

Error:
ERROR: MethodError: no method matching push!(::JSON.Object{String, Any}, ::Pair{String, String}, ::Pair{String, String})
exportObject(...) @ Modia3D.AnimationExport src/AnimationExport/exportAnimation.jl:274

Root cause:
exportAnimation.jl parses mesh companion .json files via JSON.parse(io), then mutates the result with push!(dict, "key" => value, ...). This worked with JSON.jl v0.21, where JSON.parse returned a plain Dict{String,Any}. In JSON.jl v1.x, JSON.parse returns a custom JSON.Object{K,V} <: AbstractDict (linked-list based) that implements setindex!/delete! but not push!, so these calls fail.
Affected lines are in exportAnimation.jl.

Fix:
Replace push!(dict, "key" => value) with dict["key"] = value (setindex! instead of push!), which works for both Dict and JSON.Object. I verified against JSON.jl v1.7.1 by running test/ForceElements/PCMBouncingBubbles.jl with animationFile enabled — the simulation completes and produces a valid three.js JSON animation file. I attached the modified exportAnimation.jl file (as txt, since jl is not accepted as a source code file (funny, hah))
exportAnimation

Note: the existing test suite doesn't catch this since animationFile export is commented out in the shipped PCM test files.

Activity

  1. added a commit that references this issue on Sep 4, 2026
  2. AndreaNeumayr commented on Sep 4, 2026

    @AndreaNeumayr
    Member

    I changed it. Thanks for reporting and the bug fix. Give it a try, please.

  3. added a commit that references this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions