Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
My JSON looks like this:
{Sean/Projet: 6, EC2: 1},{EC3:5,Weekend:5}
How do I dynamically access only the key, for example: "Sean/Projet" or "EC2".
Thank you.
[{Sean/Projet: 6, EC2: 1},{EC3:5,Weekend:5}]
{EC3:5,Weekend:5}
You can find that out by sorting the object by values.
var sortedKeys = keys.sort((a,b)=>{return b-a})
Add a comment
Found out a solution:
var keys = Object.keys(myJson); console.log(keys[0]);
But how do I find out which key has the greater number?
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
[{Sean/Projet: 6, EC2: 1},{EC3:5,Weekend:5}]?{EC3:5,Weekend:5}. The problem is the comma separating them, which implies an array.