Удалить все пробелы в файле - Linux

Сделайте тип метода [HttpPost], создайте модель с одним параметром int [] и отправьте сообщение с помощью json:

/* Model */
public class CategoryRequestModel 
{
    public int[] Categories { get; set; }
}

/* WebApi */
[HttpPost]
public HttpResponseMessage GetCategories(CategoryRequestModel model)
{
    HttpResponseMessage resp = null;

    try
    {
        var categories = //your code to get categories

        resp = Request.CreateResponse(HttpStatusCode.OK, categories);

    }
    catch(Exception ex)
    {
        resp = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
    }

    return resp;
}

/* jQuery */
var ajaxSettings = {
    type: 'POST',
    url: '/Categories',
    data: JSON.serialize({Categories: [1,2,3,4]}),
    contentType: 'application/json',
    success: function(data, textStatus, jqXHR)
    {
        //get categories from data
    }
};

$.ajax(ajaxSettings);
29
задан Josh Darnell 13 January 2012 в 15:41
поделиться

3 ответа

В зависимости от вашего определения пробела, что-то вроде:

tr -d ' \t\n\r\f' <inputFile >outputFile

сделает свое дело.

64
ответ дан 28 November 2019 в 00:46
поделиться
sed 's/\s//g' input.txt | tr -d '\n'
15
ответ дан 28 November 2019 в 00:46
поделиться

Если у вас есть данные UTF-8, лучше всего сделать это:

perl -CS -pe 's/\p{Space}//g' < input > output
3
ответ дан 28 November 2019 в 00:46
поделиться
Другие вопросы по тегам:

Похожие вопросы: