Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Active reading [<https://www.youtube.com/watch?v=1Dax90QyXgI&t=17m54s>].
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

Exotic one - deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;

 // ... your code

 return value;
})

In this solution we use replacer which allows to deep traverse the whole object and nested objects - on each level you will get all fields and values. If you need to get the full path to each field, look here .

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;

 console.log(`key: ${field.padEnd(11)} - value: ${value}`);

 return value;
})

Exotic one - deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;

 // ... your code

 return value;
})

In this solution we use replacer which allows to deep traverse whole object and nested objects - on each level you will get all fields and values. If you need to get full path to each field look here

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;

 console.log(`key: ${field.padEnd(11)} - value: ${value}`);

 return value;
})

Exotic one - deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 // ... your code
 return value;
})

In this solution we use replacer which allows to deep traverse the whole object and nested objects - on each level you will get all fields and values. If you need to get the full path to each field, look here .

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 console.log(`key: ${field.padEnd(11)} - value: ${value}`);
 return value;
})

Commonmark migration
Source Link

#Exotic one - deep traverse

Exotic one - deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 // ... your code
 
 return value;
})

In this solution we use replacer which allows to deep traverse whole object and nested objects - on each level you will get all fields and values. If you need to get full path to each field look here

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 console.log(`key: ${field.padEnd(11)} - value: ${value}`);
 
 return value;
})

#Exotic one - deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 // ... your code
 
 return value;
})

In this solution we use replacer which allows to deep traverse whole object and nested objects - on each level you will get all fields and values. If you need to get full path to each field look here

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 console.log(`key: ${field.padEnd(11)} - value: ${value}`);
 
 return value;
})

Exotic one - deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 // ... your code
 
 return value;
})

In this solution we use replacer which allows to deep traverse whole object and nested objects - on each level you will get all fields and values. If you need to get full path to each field look here

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 console.log(`key: ${field.padEnd(11)} - value: ${value}`);
 
 return value;
})

deleted 4 characters in body
Source Link
Kamil Kiełczewski
  • 93.8k
  • 34
  • 402
  • 375

#Exotic one - for deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 // ... your code
 
 return value;
})

In this solution we use replacer which allows to deep traverse whole object and nested objects - on each level you will get all fields and values. If you need to get full path to each field look here

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 console.log(`key: ${field.padEnd(11)} - value: ${value}`);
 
 return value;
})

#Exotic one - for deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 // ... your code
 
 return value;
})

In this solution we use replacer which allows to deep traverse whole object and nested objects - on each level you will get all fields and values. If you need to get full path to each field look here

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 console.log(`key: ${field.padEnd(11)} - value: ${value}`);
 
 return value;
})

#Exotic one - deep traverse

JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 // ... your code
 
 return value;
})

In this solution we use replacer which allows to deep traverse whole object and nested objects - on each level you will get all fields and values. If you need to get full path to each field look here

var validation_messages = {
 "key_1": {
 "your_name": "jimmy",
 "your_msg": "hello world"
 },
 "key_2": {
 "your_name": "billy",
 "your_msg": "foo equals bar",
 "deep": {
 "color": "red",
 "size": "10px"
 }
 }
}
JSON.stringify(validation_messages,(field,value)=>{
 if(!field) return value;
 
 console.log(`key: ${field.padEnd(11)} - value: ${value}`);
 
 return value;
})

added 240 characters in body
Source Link
Kamil Kiełczewski
  • 93.8k
  • 34
  • 402
  • 375
Loading
Source Link
Kamil Kiełczewski
  • 93.8k
  • 34
  • 402
  • 375
Loading
lang-js

AltStyle によって変換されたページ (->オリジナル) /