user3265817
user3265817

Reputation: 99

From my http GET JSON request to CouchDB I want to get the nested keys and values out and remove total rows and id

My GET JSON brings back from COUChDB {"total_rows":6,"offset":0,"rows":[ {"id":"51585142d8f2851d34c9b7dc8c003997","key":"itemName","value":{"nestedkey1":"nestedvalue1","nestedkey2":"nestedvalue2","nestedkey3":"nestedvalue2","nestedkey4":"nestedvalue4","nestedkey5"}},

I want to remove {"total_rows":6,"offset":0,"rows":[ {"id":"51585142d8f2851d34c9b7dc8c003997","key":"itemName"

So I am left with the wrapper/parent "value" that has the nested keys and nested values I really want and so it is presented in the following JSON format {"nestedkey1":"nestedvalue1","nestedkey2":"nestedvalue2","nestedkey3":"nestedvalue2","nestedkey4":"nestedvalue4","nestedkey5"}}, as my json

I've tried CouchB mapping/views and jquery client side function/result filtering but I'm new to this and could use some insight into achieving my objective

Upvotes: 0

Views: 278

Answers (1)

kubuntu
kubuntu

Reputation: 2535

You should be able to achieve this using jQuery on the client side. You could do this in the success callback of get()

var value = [];
$.get( "url/to/view", function( data ) {
  $.each(data.rows, function(index, row){
    value.push(row.value);
  });
});

That way, you have the rows in data.

Upvotes: 0

Related Questions