Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ObjectMapper cannot be resolved to a type

I have troubles getting JSON to work. ObjectMapper cannot be resolved. Library is imported correctly.

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONException;
import net.sf.json.util.*;

import com.fasterxml.jackson.*;

public class Json {
    private static final String jsonFilePath = "C:\\Users\\Juergen\\Desktop\\filesForExamples\\mapExample.json";

    public static void objectToJSON(HashMap<String, Mat> map) {
        //Map<String, Object> mapObject = new HashMap<String, Object>();
        ObjectMapper mapper = new ObjectMapper();

        try {
            objectMapper.writeValue(new File(jsonFilePath), map);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
like image 585
Jürgen K. Avatar asked Dec 15 '15 13:12

Jürgen K.


Video Answer


1 Answers

Add import com.fasterxml.jackson.databind.ObjectMapper; to your project.

like image 53
Vishwa Ratna Avatar answered Sep 21 '22 10:09

Vishwa Ratna