草庐IT

JSON数据处理

全部标签

javascript - 处理 ng-repeat 中的重复元素

我正在构建一个具有一种“播放列表”功能的应用程序。这表示带有ng-repeat="elementinplaylist"的ng-repeated自定义指令因为我想允许用户在播放列表中重复使用相同的元素两次,所以我尝试使用trackby$index添加。现在,令人困惑的是:当我从播放列表中删除一个元素时(我有一个函数removeElement(index),它基本上包含如下内容:$scope.removeElement=function(index){$scope.playlist.splice(index,1);}奇怪的事情发生了:该元素已从$scope.playlist中正确删除,但由

javascript - 通过 RTC 数据通道发送图像数据

我正在尝试通过DataChannel发送图像数据,但它不起作用。当刚从ctx.getImageData获取数据时,我在另一端收到一个字符串"[ObjectImageData]"。仅将数据片段转换为blob会导致错误:UncaughtNetworkError:Failedtoexecute'sendon'RTCDataChannel':Couldnotsenddata。尝试将其转换为ArrayBuffer时出现同样的错误。我应该怎么做? 最佳答案 这是我刚刚写的一个演示:http://richard.to/projects/datac

javascript - 使用 AngularJS 过滤 Firebase 数据

我在firebase中有这样的数据:firebase_data{-JGc5X37NDuvmJylmx0s:Object{name:'JohnDoe',age:21}-JGnGJlTjyAxFT-Vn48Y:Object{name:'JaneDoe',age:22}}在我的Controller中:$scope.firebase=$firebase(newFirebase("https://firebase_data.firebaseio.com"));我的看法:{{value.name}}过滤器不工作。我怎样才能使过滤器工作? 最佳答案

javascript - JSON Lint 说它是有效的但是 JSON.parse 抛出错误

我有一个简单的JSON,我需要将其解析为对象。奇怪的是它不起作用,即使我将我的JSON字符串复制并粘贴到JSONLint(http://jsonlint.com/)它会显示它是有效的。varstring='{"token":"9eebcdc435686459c0e0faac854997f3","email":"201403050007950","id":"13","updated_at":"2014-03-0510:34:51","messageguides":"[{\"name\":\"Un-namedMessagingGuide1\",\"pages\":[\"sustainabi

javascript - Fabric.js 子类化 fabric.Group - 错误 : "Cannot read property ' async' of undefined"when load from JSON

有以下问题:尝试继承fabric.Group:varCustomGroup=fabric.util.createClass(fabric.Group,{type:'customGroup',initialize:function(objects,options){options||(options={});this.callSuper('initialize',objects,options);this.set('customAttribute',options.customAttribute||'undefinedCustomAttribute');},toObject:functi

javascript - REST api 的外部数组是有效的 JSON 吗?

在Node.jswebb应用程序中使用MongoDB和Mongoskin时,我可以在集合上运行.find()以获取其所有文档。结果是一个mongodb游标。然后使用游标.toArray()方法将该游标转换为数组。[{_id:"53ea101656cb0c0407306405",key:"value",...},{_id:"53ea101656cb0c0407306405",key:"value",...},...]但这是RESTApi的有效JSON输出吗?...或者我应该将外部数组转换为对象吗?也许没关系? 最佳答案 是validJ

javascript - AngularJS 应用程序 : Load data from JSON once and use it in several controllers

我正在开发一个使用AngularJS作为框架的移动应用程序,目前我的结构与此类似:app.config(['$routeProvider',function($routeProvider){$routeProvider.when('/',{templateUrl:'pages/home.html',controller:'homeCtrl'}).when('/one',{templateUrl:'pages/one.html',controller:'oneCtrl'}).when('/two',{templateUrl:'pages/two.html',controller:'two

javascript - 如何在具有动态键值对的javascript中解析json?

这个问题在这里已经有了答案:HowdoIenumeratethepropertiesofaJavaScriptobject?[duplicate](14个答案)关闭7年前。我想用JavaScript解析一个JSON字符串。响应类似于varresponse='{"1":10,"2":10}';如何从这个json中获取每个键和值?我正在做这个-varobj=$.parseJSON(responseData);console.log(obj.count);但我得到undefinedforobj.count。

javascript - 带有撇号(单引号)的 JSON 解析字符串

如何解析下面的字符串vara=JSON.parse('['+'{"NoteName":"it'smylife","UserId":"100","NoteActive":true,"UserEmail":"admin@dev.xrc.com","CreatedDate":"8/13/20121:47:35PM"}'+']'); 最佳答案 你只需要转义一个单引号it\'svara=JSON.parse('['+'{"NoteName":"it\'smylife","UserId":"100","NoteActive":true,"Use

javascript - Materialize css select 无法处理 JS 错误

我在使用MaterializeCSS框架选择表单时遇到问题。这是我的表格:ChooseyouroptionOption1Option2Option3MaterializeMultipleSelect$('select').material_select();这是我的slim布局:doctypehtmlhtmlheadmetacontent=("text/html;charset=UTF-8")http-equiv="Content-Type"/titleBudeprace=stylesheet_link_tag'https://cdnjs.cloudflare.com/ajax/lib