P
P
prizrak392019-05-28 14:19:55
Java
prizrak39, 2019-05-28 14:19:55

How to generate json without body and success sections?

Good afternoon.
There is the following REST service method.

@GET
@Path("/getClient")
public Client getClient() {
    Client result = (Client) getJsonFile("getClient.json", Client.class);
    retrun result;
}

This code always generates json in response, which contains the success section (information about the success of the request), as well as the body section, inside which the data is located.
How can I get the response json, without the section data and so that it only consists of the data in the result object.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Sokolov, 2017-06-09
@boarworm

Split into an array by semicolon. Then split each element comma-with-space into an array of pairs of coordinates (they will be text strings "55.759906" and run through each one parseFloatto become numbers:

var coords = "55.759906, 37.622242;50.455898, 30.521481";
coords = coords.split(';').map( e => e.split(', ').map(parseFloat));
//

// или вариант для старых браузеров:
coords = coords.split(';').map( function(e){ return e.split(', ').map(parseFloat)});

R
Rsa97, 2017-06-09
@Rsa97

var coords = "55.759906, 37.622242;50.455898, 30.521481"; 
var temp = coords.match(/([0-9\.]+)\D*([0-9\.]+)\D*([0-9\.]+)\D*([0-9\.]+)/); 
coords = , [temp[3], temp[4]]];

G
GreatRash, 2017-06-09
@GreatRash

var coords = "55.759906, 37.622242;50.455898, 30.521481";
coords = coords.split(';');

coords = [coords[0].split(','), coords[1].split(',')];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question