Answer the question
In order to leave comments, you need to log in
How can I change keys in json object?
"57939553_675562008": {
"price": "5.00",
"market_hash_name": "Beast-Jaw Bludgeoner",
"ru_rarity": "Common"
}
I would like to change this name (market_hash_name), how can I do that?
Answer the question
In order to leave comments, you need to log in
Parse the JSON string into a regular object, change, "pack", as mentioned above, back.
Here are the docs: JSON Format (RU)
const json = `{"57939553_675562008": {
"price": "5.00",
"market_hash_name": "Beast-Jaw Bludgeoner",
"ru_rarity": "Common"
}}`;
const data = JSON.parse(json);
data['57939553_675562008'].custom_hash_name = data['57939553_675562008'].market_hash_name;
delete data['57939553_675562008'].market_hash_name;
const result = JSON.stringify(data);
console.log(result);
const data = JSON.parse(json);
delete Object.assign(data, {
'57939553_675562008': {
new_name: data['57939553_675562008'].market_hash_name,
...data['57939553_675562008']
}
})['57939553_675562008']['market_hash_name'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question