产生的错误说“keyvalue pair不是一个函数” [英] arising error saying "keyvalue pair is not a function "

查看:134
本文介绍了产生的错误说“keyvalue pair不是一个函数”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码在数据中存储ID和名称

i am using this code to store id and name in data

productarranging{};
productpair=[];

productarranging=JSON.parse("some values");
productpair=productarranging.keyvaluepair("name","id");
var data=productarranging.tolabelvalue("name","name");

推荐答案

JSON.parse(_方法从包含json格式数据的字符串中创建JavaScript对象。

例如

JSON.parse(_ method creates a JavaScript object out of a string that contains a json formatted data.
For instance
var o = JSON.parse('"a": 1, "b": 2');



将创建一个具有两个属性的对象,一个名为a,另一个名为b,值分别为1和2 ......

因为它是标准的JavaScript对象,所以你必须以一个标准的JavaScript对象


will create an object with two properties, one named a and the other named b with value 1 and 2 respectively...
As it is a standard JavaScript object you have to access it as a standard JavaScript object

o.a
// or
o["a"]



没有像'keyvaluepair'这样的函数,没有例如'tolabelvalue'...


There is no such function around like 'keyvaluepair' and no such as 'tolabelvalue'...


这篇关于产生的错误说“keyvalue pair不是一个函数”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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