Skip to content

Prevent keywords as values from being converted into strings on change? #1

@ryrobes

Description

@ryrobes

Hi, I was curious if it was possible to avoid keyword values from being cast into strings for the return model on-change?

{:my-key :my-value} will always be changed to {:my-key "my-value"} even if that part of the tree isn't being modified - probably not possible, since keywords as values are not a thing in js (edn -> js -> edn is "lossy" in a way I suppose), but thought it was worth asking.

Edit: Looks like even "keys" for vectors get the same treatment, empty maps get removed altogether, and some other strange mutations are happening.

Raw incoming EDN to model:

{:json-test {:root {:map-key1 [:vec-keyword1 :vec-keyword2 :vec-keyword3 :vec-keyword1 ["thing1" "thing2" :new-map {:key11 [1 2 3 4]} :vec3 [:test1 :test2 2 3 4]]]}, :other {}}}

After update w json-editor (changing string "thing1" to "thing1a"):

10x diff - only before:

{:json-test {:root [:map-key1 [:vec-keyword1 :vec-keyword2 :vec-keyword3 :vec-keyword1 "thing1" nil :new-map nil :vec3 [:test1 :test2]]]}}

10x diff - only after:

{:json-test {:root [:map-key1 ["vec-keyword1" "vec-keyword2" "vec-keyword3" "vec-keyword1" "thing1a" nil "new-map" nil "vec3" ["test1" "test2"]]]}}

Added an image since the EDN formatting is going to get ruined.

image

Oh, and if I try and be cheeky and add a colon to the front of a keyword that I know is going to be stringified, most of the rest of the map gets destroyed in the update process.

Thanks Isaac! Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions