Remove a JSON attribute

if I have a JSON object say:

var myObj = {'test' : {'key1' : 'value', 'key2': 'value'}}

can I remove ‘key1’ so it becomes:

{'test' : {'key2': 'value'}}

PostgreSQL: Remove attribute from JSON column

I need to remove some attributes from a json type column. The Table: CREATE TABLE my_table( id VARCHAR(80), data json); INSERT INTO my_table (id, data) VALUES ( ‘A’, ‘{attrA:1,attrB:true,attrC:[

remove json attribute where attribute is a variable

I have a news feed where items in the feed are created from JSON returned from a server. When the user takes an action on an item, I want to remove it from the object via javascript. The feed looks li

How to globally remove attribute from Jackson JSON serialization?

I have an object graph that contains objects that are (for purposes of this example) subclasses of type Foo. The Foo class has an attribute on it called bar that I do not want to be serialized with my

Detect type of JSON attribute

JSON: {attribute1:11, attribute2:string atribute} I want to detect what kind of type are attribute1 and attribute2: attribute1 is integer attribute2 is string jsonObject.getAttributeType(att

remove extended attribute : fails

From a shell script, I’m trying to remove extended attribute setfattr -x security.selinux file.txt The file.txt has mode as 777 but im getting permission denied error How to fix this

Remove CSS attribute using Jquery

All of the other answers I have discovered only remove the setting of the attribute, and not the attribute completely. I am changing an element from absolute to fixed positioning. I need to remove the

Remove json element

I want to remove JSON element or one whole row from JSON. I have following JSON string: { result:[ { FirstName: Test1, LastName: User, }, { FirstName: user, LastName: user, }, { Fir

XPATH remove attribute

Hi does anyone know hwo to remove an attrbute using xpath. In particular the rel attribute and its text from a link. i.e. <a href=’’ rel=’some text’>Link</a> and i want to

Remove attribute of HTML element

Following this question: Modify attribute of element, I would like to know if there is a clean way to remove an attribute in Lift. For now I directly run the javascript command: Run(document.getElem

Cannot add/remove attribute onclick

I am new to javascript and jQuery. I am trying to add an attribute on click and remove it on click. I have add and remove class working well but not attribute. My code is below. HTML below <label c



delete myObj.test.key1;

The selected answer would work for as long as you know the key itself that you want to delete but if it should be truly dynamic you would need to use the [] notation instead of the dot notation.

For example:

var keyToDelete = "key1";
var myObj: {"test": {"key1": "value", "key2": "value"}}

delete myObj.test.keyToDelete //would not work.

instead you would need to use:

delete myObj.test[keyToDelete];

Substitute the dot notation with [] notation for those values that you want evaluated before being deleted.