从json删除空值 [英] delete null value from json

查看:128
本文介绍了从json删除空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究JSON,现在我有新的问题创建,当我从JSON中删除一个项目时它将删除该索引上的所有项目之后在该地方插入null现在我的问题是我也想索引的JSON对象



演示 这里



在这个小提琴这些步骤如下(请按照此步骤):


  1. 在购物车中添加商品

  2. 现在点击转到购物车。

  3. 现在点击删除按钮

生成警报框,看到JSON的第一个索引,它将显示为null,我想从JSON中删除该索引

解决方案

.splice(0,1);


I am working on JSON, now i have new issue create, when i'm delete an item from JSON it will delete the all item on that index after this on that place null are inserted now my problem is i want also index of that JSON object

Demo Here

In this Fiddle these step follow (Please follow this step):

  1. Add item in cart
  2. Now click on Go to cart.
  3. Now click delete button

A alert box generate, see the first index of JSON it will be show null, i want delete that index from JSON

解决方案

Try this it will work

objArray.splice(0,1);

这篇关于从json删除空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆