草庐IT

json_array

全部标签

javascript - 为什么 Array + Array 等于空字符串?

我看过这个很有趣screencast昨天关于Ruby和Javascript等语言的一些奇怪之处,那个人表明:[]+[]->""//returnsemptystring不是很明显...我决定去ECMAscriptlanguagespecification获取更多信息。我从+运算符实现(第75页)开始,它说:11.6.1TheAdditionoperator(+)Theadditionoperatoreitherperformsstringconcatenationornumericaddition.TheproductionAdditiveExpression:AdditiveExpre

javascript - 为什么我不能覆盖 `Array` (`Array.prototype` 的原型(prototype))?

我把Array的原型(prototype)设置为my的实例,我想book.aa会显示"aa",却显示"undefined",为什么?谢谢!ArrayPropertiesArrayPropertiesfunctionmy(){this.aa='aa';}Array.prototype=newmy();Array.prototype.bb="bb";varbook=newArray();book[0]="WarandPeace";document.write(book.aa+book.bb); 最佳答案 您不能分配给Array.prot

javascript - 如何通过 JSON 传递函数名称并在 javascript/jQuery 中调用它?

我有一个JSON字符串,其中包含我需要调用的函数。我的JSON看起来像这样:{"type":"listview",//thefunctionIwouldliketocall"content":"dynoData.getRetailers()","custom_classes":["","nMTpickList","",""],"lib":"static_listview.html","tmp":"tmp_listview_inset","lang":"locale_search",...我正在使用它在客户端上组装一个jQueryMobileListView。要获取动态数据,我需要调用d

javascript - jQuery 中附加 [object%20Object] 的 JSON 请求

我正在尝试使用getJSON方法获取我用jQuery编写的自定义JSON提要。由于未知原因,URL似乎从末尾删除了cache_gen.php?location=PL4并替换为[object%20Object],导致发生404错误。这是我正在使用的jQuery:varfetchData=function(){if(Modernizr.localstorage){varapi_location="http://weatherapp.dev/cache_gen.php";varuser_location="PL4";vardate=newDate();console.log(api_loca

javascript - 如何从 JSON 字典中按键检索随机 JSON 对象?

我有一个JSON对象,它由一长串其他JSON对象组成,这些对象具有一些共同的属性,例如:varmyData={"0291":{"Firstname":"Jeremy","Surname":"Dyson"},"0398":{"Firstnname":"Billy","Surname":"Bunter"},"6714":{"Firstnname":"Harry","Surname":"Peterson"},"9080":{"Firstnname":"Barry","secondname":"Joe","Surname":"Mainwaring"}......}我已经构建了一个html模板。

javascript - 将 JSON 数组放入 Handlebars

我有一个json对象作为["id","birthday","companymsgsthisperiod","companythisperiodend","cust_attr_boolean","subscribed","testgroup","usermsgsthisperiod","userthisperiodend"]现在我想使用Handlebars将这种类型的json对象添加到文件中/*json*/谁能帮我解决这个问题? 最佳答案 你有一个数组。我猜来自documentation你可以使用eachblock助手{{#eachd

javascript - 为什么 JSON 结果可以是 bool 值而不是对象或数组?

来自JSONwebsite:JSONisbuiltontwostructures:Acollectionofname/valuepairs.Invariouslanguages,thisisrealizedasanobject,record,struct,dictionary,hashtable,keyedlist,orassociativearray.Anorderedlistofvalues.Inmostlanguages,thisisrealizedasanarray,vector,list,orsequence.现在我有一个返回bool值的示例服务(这是在PHP中,但它可以是任

javascript - 如何使用 JSON Schema 验证表单?

我想使用描述它的JSON模式来验证来自HTML表单的输入。我正在使用GaryCourt的JSV来验证它,它始终返回错误。我使用JSONSchemaLint(jsonschemalint.com)检查我的模式。在Chrome模式中,Lint告诉我我的模式有效,但在Firefox、Safari和Opera中,该网站告诉我我的模式是有效的JSON但不是有效的JSON模式。谁能帮我吗。我的架构如下。UPDATE8/6/13感谢您的所有回复。我更新的JSON(更新如下)现在可以在所有浏览器中验证。但是我仍然从JSV收到以下错误:Report{errors:Array[1],validated:O

javascript - typeof (Array, null) 返回对象,typeof(null, Array) 返回函数

正如标题所说的那样,typeof(Array,null)返回object而typeof(null,Array)返回函数。它返回第二个参数的类型。为什么? 最佳答案 因为typeof是一个运算符,不是一个函数,所以typeof(expr)是typeofexpr,用exprevaluatedfirsta,breturnsb所以typeof(a,b)返回typeofb在你的情况下typeof(Array,null)是typeofnullwhichis"object"typeof(null,Array)是typeofArray,Array是

javascript - 在新的浏览器标签页中显示json

我已经尝试了4天来解决这个问题。但是我无法将json数据返回到新的标签页中。我的代码:functionCustomerId(){varurl="Home/PanelGoster";//MyURLvarveri={Id:Id.GetValue(),};$.ajax({url:"/Home/PanelGoster",type:"POST",dataType:"json",contentType:'application/json',data:JSON.stringify(veri),success:function(mydata){if(mydata.error6==true){}else