Convenience method to create responses in the "standard wrapped results" style.
<pre>
{
"results": [
item,
item,
...
],
"success": true
}
</pre>
496719
public static <T> Builder<T> wrappedResultsArrayOf(TypeReference<T> type)
    {
        return builder(type).withHeader(StandardStreamCallbacks.RESULTS_HEADER).withFooter(StandardStreamCallbacks.RESULTS_FOOTER);
    }
284567
def wrapped_resource(response):
    
    # decode response text, assuming utf-8 if unset
    response_content = response.content.decode(response.encoding or 'utf-8')

    try:
        content = json.loads(response_content)
    except ValueError:
        # not JSON
        content = response_content
    if isinstance(content, list):
        result = ResourceList(content)
    else:
        result = Resource(content)
        if hasattr(result, 'collection'):
            result.collection = ResourceList(result.collection)
    result.raw_data = response_content

    for attr in ('encoding', 'url', 'status_code', 'reason'):
        setattr(result, attr, getattr(response, attr))

    return result
560577
def create_detailed_results(result):
    
    string = ""
    # Validation Response output
    # string += "VALIDATION RESPONSE\n"
    string += "STATUS: {}\n".format(result["status"])
    if result["feedback"]:
        string += "WARNINGS: {}\n".format(len(result["feedback"]["wrnMsgs"]))
        # Loop through and output the Warnings
        for msg in result["feedback"]["wrnMsgs"]:
            string += "- {}\n".format(msg)
        string += "ERRORS: {}\n".format(len(result["feedback"]["errMsgs"]))
        # Loop through and output the Errors
        for msg in result["feedback"]["errMsgs"]:
            string += "- {}\n".format(msg)
    return string
669054
def print_rendered_results(results_dict):
    
    class _HubComponentEncoder(json.JSONEncoder):
        def default(self, o):
            if isinstance(o, base.HubComponent):
                return repr(o)
            return json.JSONEncoder.default(self, o)
    formatted = json.dumps(results_dict, indent=4, cls=_HubComponentEncoder)
    # the returned string contains lines with trailing spaces, which causes
    # doctests to fail.  So fix that here.
    for s in formatted.splitlines():
        print(s.rstrip())
515312
def get_response(self, results):
        
        if results is None:
            return None
        for result in itertools.chain.from_iterable(results):
            if isinstance(result, BaseResponse):
                return result
350905
def _make_json_result(code, message="", results=None):
    
    return code, json.dumps({'code': code,
                             'message': message,
                             'results': results})
191846
private ObjectNode createResponseSuccess(String jsonRpc, Object id, JsonNode result) {
		ObjectNode response = mapper.createObjectNode();
		response.put(JSONRPC, jsonRpc);
		if (Integer.class.isInstance(id)) {
			response.put(ID, Integer.class.cast(id).intValue());
		} else if (Long.class.isInstance(id)) {
			response.put(ID, Long.class.cast(id).longValue());
		} else if (Float.class.isInstance(id)) {
			response.put(ID, Float.class.cast(id).floatValue());
		} else if (Double.class.isInstance(id)) {
			response.put(ID, Double.class.cast(id).doubleValue());
		} else if (BigDecimal.class.isInstance(id)) {
			response.put(ID, BigDecimal.class.cast(id));
		} else {
			response.put(ID, String.class.cast(id));
		}
		response.set(RESULT, result);
		return response;
	}
394740
def build_result(data):
    """"""
    more = {}
    for key, value  in data.items():
        if key != 'elements':
            newnode = value
        else:
            newnode = {}
            for el in value:
                nkey, nvalue = process_node(el)
                newnode[nkey] = nvalue

        more[key] = newnode

    return more
1131156
function renderSearchResults(items){
    var html = '';

    // Loop through items, building up an HTML string
    for(var i = 0; i < items.length; i += 1){
      var f = items[i];
      html += [
        '<a class="item" data-value="', f.fullPath, '.html">',
          '<span class="score">', ~~f.score, '</span>',
          '<span class="filename">', highlightString(f.fileName, f.highlight.fileName), '</span>',
          '<span class="fullpath">', highlightString(f.fullPath, f.highlight.fullPath), '</span>',
        '</a>'
      ].join('');
    }

    // Dump all the html into the results list
    document.getElementById('searchresults').innerHTML = html;

    // Select the first item
    selectIndex(0);
  }
412565
function(dbresult) {
        // start with response header
        var jsonresponse= // validate syntaxe at http://geojsonlint.com/
          {"type":"GeometryCollection"
          ,"device":
            {"type":"Device"
            ,"class":device.class
            ,"model": device.model
            ,"call": device.call
          },"properties":
            {"type":"Properties"
            ,'id'  : query.devid
            ,"name": device.name
            ,'url': devurl
            ,'img': device.img
          }
          ,"geometries":[]             
          };       
     
        for (var idx in dbresult) {
            var pos = dbresult [idx];
            var ptsinfo=util.format ("%s<br>Position:[%s,%s] Speed:%s",pos.date,pos.lon.toFixed(4),pos.lat.toFixed(4),pos.sog.toFixed(1));
            jsonresponse.geometries.push (
                   {'type':'Point'
                    ,'coordinates' :[pos.lon, pos.lat]
                    ,'sog' : pos.sog
                    ,'cog' : pos.cog
                    ,'date' : pos.date.getTime()
                    ,'properties'  :
                        {'type':'Properties'
                        ,"title": ptsinfo 
                    }});
           };
    if (query.jsoncallback === undefined) {
        response.writeHead(200,{"Content-Type": "application/json"});  
        response.write(JSON.stringify(jsonresponse));
    } else {
        response.writeHead(200,{"Content-Type": "text/javascript",'Cache-Control':'no-cache'});  
        var fakescript=query.jsoncallback +'(' + JSON.stringify(jsonresponse) +');';
        response.write (fakescript);
    }      
    response.end(); 
    }
1320899
public static String wrapInTableRow(final List<String> items) {
        final StringBuilder output = new StringBuilder("<row>");
        for (final String entry : items) {
            output.append("<entry>" + entry + "</entry>");
        }

        output.append("</row>");
        return output.toString();
    }
614647
function resultRaw (results) {
    // throw error if results required and not retrieved
    if (this.args.required && !results.length) {
        // throw error
        throw this.error('no records found')
    }
    // if only ids were selected the return result object to fetch records
    if (this.select.isSelectOnlyIds) {
        // build result object
        var result = new ImmutableCoreModelResult({
            query: this,
            results: results,
        })
        // return result or all records if specified
        return this.args.all ? result.all() : result
    }
    // otherwise return ImmutableCoreModelInstance record(s)
    else {
        // query is for a single record
        if (this.args.limit === 1) {
            // return new instance or undefined
            return results.length
                ? this.newInstance(results[0])
                : undefined
        }
        // query is for multiple records
        else {
            return _.map(results, result => this.newInstance(result))
        }
    }
}
332231
def success_response(**data):
    """"""
    data_out = {}
    data_out["status"] = "success"
    data_out.update(data)
    js = dumps(data_out, default=date_handler)
    return Response(js, status=200, mimetype="application/json")
266570
def serialize_list(self, data):
        
        if data is None:
            return ''

        # Check for a ``Data``-like object. We should assume ``True`` (all
        # data gets prepared) unless it's explicitly marked as not.
        if not getattr(data, 'should_prepare', True):
            prepped_data = data.value
        else:
            prepped_data = [self.prepare(item) for item in data]

        final_data = self.wrap_list_response(prepped_data)
        return self.serializer.serialize(final_data)
478754
def _generate_result(self, res_type, channel, result):
        """"""
        schema = self.api.ws_result_schema()
        schema.context['channel'] = channel
        schema.context['response_type'] = res_type
        self.callback(schema.load(result), self.context)
1042321
private List<TestCaseResult> createResultFromMap(IResultMap resultMap) {
        logger.entering(resultMap);
        List<TestCaseResult> statusWiseResults = new ArrayList<TestCaseResult>();

        for (ITestResult singleMethodResult : resultMap.getAllResults()) {
            TestCaseResult tcresult1 = new TestCaseResult();
            tcresult1.setITestResultobj(singleMethodResult);
            statusWiseResults.add(tcresult1);

        }
        Collections.sort(statusWiseResults);
        logger.exiting(statusWiseResults);
        return statusWiseResults;
    }
1212192
def __standardize_result(status, message, data=None, debug_msg=None):
    '''
    
    '''
    result = {
        'status': status,
        'message': message
    }

    if data is not None:
        result['return'] = data

    if debug_msg is not None and debug:
        result['debug'] = debug_msg

    return result