What is the simplest way to search in JSON by attribute?

Use Array.prototype.filter function in vanilla JS to filter out the object - see demo below:

var obj={names:[{id:17,user_id:9,code:"de",name:"Ich bin Hans",created_at:"2017-07-31 12:43:19",updated_at:"2017-07-31 12:43:19"},{id:18,user_id:9,code:"en",name:"My name is Hans",created_at:"2017-07-31 12:43:19",updated_at:"2017-07-31 12:43:19"}]};

var result = obj.names.filter(function(e){return e.code == 'en'})
console.log(result);

ES6 version is even simpler:

var obj={names:[{id:17,user_id:9,code:"de",name:"Ich bin Hans",created_at:"2017-07-31 12:43:19",updated_at:"2017-07-31 12:43:19"},{id:18,user_id:9,code:"en",name:"My name is Hans",created_at:"2017-07-31 12:43:19",updated_at:"2017-07-31 12:43:19"}]};

var result = obj.names.filter(e => e.code == 'en');
console.log(result);


Use Jquery grep function. Actually you are not searching object, you are searching though an array of objects (names).

Finds the elements of an array which satisfy a filter function. The original array is not affected.

 var input = {names:[{id:17,user_id:9,code:"de",name:"Ich bin Hans",created_at:"2017-07-31 12:43:19",updated_at:"2017-07-31 12:43:19"},{id:18,user_id:9,code:"en",name:"My name is Hans",created_at:"2017-07-31 12:43:19",updated_at:"2017-07-31 12:43:19"}]};
 
var result = $.grep(input.names, function(obj) {
    return obj.code === "en";
});
console.log(result);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Another is Array#find function

var input = {names:[{id:17,user_id:9,code:"de",name:"Ich bin Hans",created_at:"2017-07-31 12:43:19",updated_at:"2017-07-31 12:43:19"},{id:18,user_id:9,code:"en",name:"My name is Hans",created_at:"2017-07-31 12:43:19",updated_at:"2017-07-31 12:43:19"}]};
 
var result = input.names.find(item => {
   return item.code == 'en'
})
console.log(result);