trouble with JSON array

eric's Avatar


15 Oct, 2013 03:29 PM

When I'm trying to make a JSON array out of my JSON object in Java I get the error Duplicate key "cached_queue_list"

Here is my code

package client_RMA;

import org.json.JSONArray;
import org.json.JSONObject;

public class client0 {
    private final String USER_AGENT = "application/vnd.tender-v1+json";

    public static void main(String[] args) throws Exception {

        client0 http = new client0();

        System.out.println("Testing 1 - Send Http GET request");

        System.out.println("\nTesting 2 - Send Http POST request");
        http.sendPost();// not implemented yet


    // HTTP GET request
    private void sendGet() throws Exception {

        String url = "";

        URL obj = new URL(url);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();

        // optional default is GET

        //add request header
        con.setRequestProperty("Accept", USER_AGENT);

        int responseCode = con.getResponseCode();
        System.out.println("\nSending 'GET' request to URL : " + url);
        System.out.println("Response Code : " + responseCode);

        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;
        StringBuilder response = new StringBuilder();

        while ((inputLine = in.readLine()) != null) {

        // System.out.println(response.toString());
        String pootis = response.toString();

        JSONObject jobj = new JSONObject(pootis);
        // A Simple JSONObject Parsing
        JSONArray array = jobj.getJSONArray("discussions");
  1. 1 Posted by Julien on 15 Oct, 2013 07:21 PM

    Julien's Avatar

    Hey Eric,

    I got the same error, though I'm not sure why. The JSON itself doesn't have a duplicate key, so I would recommend trying out a different library, maybe gson, and see if you get better results.

  2. 2 Posted by eric on 16 Oct, 2013 08:05 PM

    eric's Avatar

    gson is working for me. Thank you very much

  3. Julien closed this discussion on 16 Oct, 2013 08:37 PM.

Discussions are closed to public comments.
If you need help with Tender please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac