0

i am using the below json file

{
    "@odata.context": "http://services.odata.org/V4/(S(ssjoqalpf5sovrqt2mkbpj2t))/TripPinServiceRW/$metadata#People('russellwhyte')/Trips",
    "value": [
        {
            "tripId": 0,
            "shareId": "9d9b2fa0-efbf-490e-a5e3-bac8f7d47354",
            "description": "Trip from San Francisco to New York City. Nice trip with two friends. It is a 4 days' trip. We actually had a client meeting, but we also took one to go sightseeings in New York.",
            "name": "Trip in US",
            "budget": 3000,
            "startsAt": "2014-01-01T00:00:00Z",
            "endsAt": "2014-01-04T00:00:00Z",
            ]
        }
    ]
}

But i am getting error while parsing the file...below is my java code

public static void main(String[] args) {
        Employee employee = null;
        ObjectMapper mapper = new ObjectMapper();
        //mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

        try {
            employee = mapper.readValue(new File("C:/Users/vikram.b.ravi/Desktop/trip.json"),
                    Employee.class);
        } catch (JsonGenerationException e) {
            e.printStackTrace();
        } catch (JsonMappingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(employee);
    }

***The error i am getting

org.codehaus.jackson.JsonParseException: Unexpected character (']' (code 93)): was expecting double-quote to start field name
 at [Source: C:\Users\vikram.b.ravi\Desktop\trip.json; line: 12, column: 14]null***

Kindly help me how to suppress the special characters in the JSON file????

1
  • Can you wrap the json text as source code (4 space indentation) to increase its readability? Commented Jan 21, 2015 at 13:44

1 Answer 1

1

Your json is not valid.

You have to remove the comma at end of line "endsAt" and the first [ has to be deleted:

{
        "@odata.context": "http://services.odata.org/V4/(S(ssjoqalpf5sovrqt2mkbpj2t))/TripPinServiceRW/$metadata#People('russellwhyte')/Trips",
        "value": [
            {
                "tripId": 0,
                "shareId": "9d9b2fa0-efbf-490e-a5e3-bac8f7d47354",
                "description": "Trip from San Francisco to New York City. Nice trip with two friends. It is a 4 days' trip. We actually had a client meeting, but we also took one to go sightseeings in New York.",
                "name": "Trip in US",
                "budget": 3000,
                "startsAt": "2014-01-01T00:00:00Z",
                "endsAt": "2014-01-04T00:00:00Z"
            }
        ]
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.