I am trying to filter this JSON object by the keys:
The data looks like this
key1: value1
key2: value2
key3: value3
key4: value4
key5: value5
key6: value6
key7: value7
key8: value8
key9: value9
Currently what I am doing right now is renaming the keys to fit that strucure and then try to filter it out.
var reassaignedKeys;
props.data.map((entries, valuesIndex) => {
reassaignedKeys = Object.assign({}, {Owner: entries[0], ApplicationId: entries[1], ApplicationName: entries[2], Status: entries[3], DeploymentStatus: entries[4], Classification: entries[5], PersonalBindle: entries[6], PerviouslyCertified: entries[7], Goal: entries[8]})
})
console.log(reassaignedKeys)
This code above is what I am using to rename the keys, I am now confused on how to filter out the key and value using the key.
I know I can use
Object.keys.filter
But I am not getting the results I want is it keeps returning the same array back to me
2
Answers
I don’t quite understand what you wan’t, but if you want get keys or key-values pairs, and assuming that your
JSON
is correctlike this.
Than you can do
JSON.parse
to parse yourJSON
toJS
object, and useYou can make something like this :
You can also use lodash pickBy or omitBy functions