I'm studying Spring Boot and I know how to read JSON file from resources directory but I want to get particular data, not whole data. like localhost:8080/user returns user name.
below is my current code
package com.example;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.core.io.Resource;
import org.springframework.web.bind.annotation.*;
@RestController
@EnableAutoConfiguration
public class HelloWorld {
@Value("classpath:json/test.json")
private Resource resourceFile;
@RequestMapping("/")
Resource home() {
return resourceFile;
}
public static void main(String[] args) throws Exception {
SpringApplication.run(HelloWorld.class, args);
}
}
I want to read particular data in the test.json file. please give me some advice or steps. Thanks