Answer the question
In order to leave comments, you need to log in
How to get JSON (JS) values?
var x = {} //JSON и его значения
var str = JSON.stringify(x); //далее мы переводим в строку
Answer the question
In order to leave comments, you need to log in
var x = {
key1: 12345678,
key2: "12345429",
key3: "2914180512305"
}
var f = Object.keys(x).filter(function(w) {
v = x[w];
if (typeof v !== "string") {
v = w.toString()
}
return w.match(/^1234\d{4}$/)
}).map(function(k) {
return x[k]
})
var x = {
key1: 12345678,
key2: "12345429",
key3: "2914180512305"
}, f = [];
Object.keys(x).forEach(function(k, v) {
if (typeof v !== "string") {
v = v.toString()
}
if (v.match(/^1234\d{4}$/)) f.push(v)
})
var x = {
key1: 'dumbvalue',
key2: '12345678',
key3: '11234567'
};
var regex = /^1234/;
var results = Object.keys(x).filter(function(key) {
if (typeof x[key] === 'string') {
return x[key].match(regex) !== null;
}
return false;
}).map(function(key) {
return x[key];
});
console.log(results);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question