Linked Questions
89 questions linked to/from JavaScript: Object Rename Key
0
votes
1
answer
10k
views
Rename the object key [duplicate]
I have an array of objects where I want to rename the key name as shown:
let Options = [{Code: 1, Label: 'abc'}, {Code: 2, Label: 'xyz'}, {Code: 3, Label: 'fgh'}];
I want to change the key 'Code' to '...
3
votes
2
answers
822
views
Modify object's keys without creating new object [duplicate]
I have following input:
{
foo: 4,
bar: 3
}
I want to modify the keys of this object to get:
{
x_foo_y: 4,
x_bar_y: 3
}
Is it possible to modify the object without creating new one ? (jQuery ...
2
votes
2
answers
6k
views
How to change object key in react [duplicate]
I have an object like
{Text Field 1: {fieldName: "Text Field 1", fieldType: "text", data: "custom value"},
Text Field 2: {fieldName: "Text Field 3", fieldType: &...
1
vote
4
answers
224
views
How to rename the existing object's key using java-script /Angular? [duplicate]
I have an existing object,
this.data = {
"part": "aircraft",
"subid": "wing",
"information.data.keyword": "test",
"fuel.keyword": "lt(6)"
}
What I'm trying to do is to check every key and ...
1
vote
1
answer
874
views
Rename a field in each object of a list [duplicate]
I have a list of object, each object has a field name:
let data = [{name: 'foo'}, {name: 'bar'}, {name: 'ipsum'}];
I would like to rename the name field to title. I tried following:
data.map(el => ...
-1
votes
1
answer
1k
views
How to remap each key of one Object to the value of another? [duplicate]
Let's say I have an object named data:
{
first: 'Zaaac',
last: 'Ezzell',
title: 'Mrs',
mail: '[email protected]',
cellphone: '+444444',
phone_2: '6506679207',
address_2: ...
0
votes
2
answers
711
views
How to change a Key in Object if Key value is number? [duplicate]
I'm new to javascript and have a question : i want to change keys if their value is number for example. What's wrong with my code?
const order = {
wine : 100,
vodka : 200,
beer : 300,
...
-1
votes
2
answers
323
views
change key names of JSON using array [duplicate]
Say I have some JSON data like this:
blah = [
{"Species":"setosa","Sepal.Length":5.1,"Sepal.Width":3.5},{"Species":"setosa","Sepal.Length":4.9,"Sepal.Width":3}
]
In my code, I won't necessarily know ...
0
votes
2
answers
151
views
How to rename key of object with a variable? [duplicate]
I have got an object:
blocks: [
{
type: 'animal',
data: { text: 'Bark bark' }
},
{
type: 'human',
data: { text: 'Speak speak' }
},
...
]
The data: naming does not fit my ...
0
votes
0
answers
272
views
Changing fields in a JSON object in Node.js [duplicate]
I have the following JSON object:
{
"_id": "123",
"name": "aa",
"description": "sdweok",
"category": "11123",
"tags": ["aasdsd"],
"extraData": {
"brand" : "oksdf",
...
-2
votes
1
answer
233
views
Redefine object properties keys starting with prefix [duplicate]
If I have the following object, how can I redefine the keys to remove the prefix "Class"?
{
ClassName: "John",
ClassEmail: "[email protected]",
ClassPhone: "...
0
votes
1
answer
136
views
Best way to handle diferent keys in multiple apis responses [duplicate]
I'am trying to develop a nodejs service that will work as a proxy between my apis and third party apis. What I need to implement is a system capable of receiving multiple api responses and "translate" ...
1
vote
3
answers
163
views
What is the most efficient way to update a key inside of an array of objects in Javascript? [duplicate]
If I have a JavaScript array including 10 objects with the following syntax:
const myArray = [{Age: 10, Name: Justin}, {Age: 15, Name: Bob}, ..., {Age: 20, Name: Jon}];
What's the most efficient way ...
-1
votes
1
answer
121
views
How to change array name inside of an object [duplicate]
Guys Im a bit new to javascript. I have the following code. I need to assign a string name to the data object. How can I convert this object
const obj= { data: [
{ name: "subject", note: ...
0
votes
0
answers
62
views
Accessing and editing nested object keys in JavaScript through path [duplicate]
I want to access and edit a **nested ** key in the object (not the value but the key itself).
eg;
{
"name": {
"firstname": "Boba",
"lastName": "...