Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

UPDATE: Solved thanks To @AmeliaBR, that answered my specific question here after I asked it.

  • This fiddle shows the adaptation of the solution to my specific problem.


My question was:

  • I'm looking for something like this without changing the structure of the functions I want to use.

  • This works great if you have defined parents inside the structure, but I can't get access to it.

What I ideally would do is to also do it work efficiently, and I think that in order to do so nest() might be a good answer.

I want to change

"key": "keyname", "values":"a value" 

into

"name": "keyname", "children":"a value"

And in the leaf node change (if possible making the rest of useless data dissapear)

 "value": "a value" 

into

"size": "a value"

I got a bit sad when I read this:

"I don't see any other method than going trough all elements recursively and changing names, which requires copying and deleting each field. However you can always use the source code of nest() as inspiration."

Can you beat that guy with your knowledge?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
459 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...