rupGo
rupGo

Reputation: 410

Is there a maximum length for json in Java?

I'm getting an output of the classes that students saw through all the university career.

this is an example of the output

{
    "HISTORICOP": [
        {
            "MATERIA": "PROCESOS DEL LENGUAJE ",
            "NOTA": "7 ",
            "ANIO": "2000",
            "PERIODO": "001",
            "ENEMENOSUNO": "0 "
        },
        {
            "MATERIA": "RAZONAMIENTO BASICO FG ",
            "NOTA": "13 ",
            "ANIO": "2000",
            "PERIODO": "001",
            "ENEMENOSUNO": "0 "
        },
        {
            "MATERIA": "DESARROLLO DE COMPETENCIAS ",
            "NOTA": "8 ",
            "ANIO": "2000",
            "PERIODO": "001",
            "ENEMENOSUNO": "n-1 "
        }
    ]
}

these are 3 of the results

but the whole output are 91 results, when I run it on a emulator the blackberry is not able to read it but when I try with less results he can read it!

Is there a maximum json length size so it can be read in java?

this is how I retrieve the info! from SAP

try {
    $conn = new sapnwrfc($config);
    $fds = $conn->function_lookup("ZCM_GET_HORARIO");
    $parms = array('CEDULA' => '16814224');
    $results = $fds->invoke($parms);
    echo "[".json_encode($results)."]";

    $conn->close();
} catch (Exception $e) {
        echo "Connection Failed 3";
}

Upvotes: 2

Views: 5696

Answers (1)

mcherm
mcherm

Reputation: 24656

There is no absolute limitation in JSON. In Java there is a limit to the length of a String, which is 2^31-1 or over 2 billion characters long. But given the snippet of code you showed us you are not actually using Java (Java doesn't have "$" before variable names).

There may be a limitation in whatever library you are using which is not a fundamental limitation of the data format or the language.

But if you are having problems with just 91 items (not 91 thousand or 91 million) then it is far more likely that you problem is NOT due to a fundamental size limitation. If you post more about what actual errors you saw you might get a more useful response.

Upvotes: 4

Related Questions