0
I’m having a problem returning a very large integer value in JSON type:
{“matricula”: 201737909200976697}
What happens is that in return is bringing 201737909200976700.
This occurs with any large 18-digit integer, so I wanted to return this value as a string but in Javascript it is still coming as a numeric value.
How can I make it right?
EDIT 1:
From php comes out like this:
array (
0 =>
array (
'mtr_codigo' => '2586',
'aln_nome' => 'JOSÉ FERNANDO REIS',
'mtr_matricula' => '201737909200976697'
),
)
When it arrives in javascript is:
[{"mtr_codigo": 2586, "aln_nome": "JOSÉ FERNANDO REIS", "mtr_matricula": 201737909200976700}]
EDIT 2:
In the Devtools of Chrome in the part Sponse is like this:
{"body":[{"mtr_codigo":2586,"aln_nome":"JOS\u00c9 FERNANDO REIS","mtr_matricula":201737909200976697}],"meta":{"output":[]},"status":{"code":200,"phrase":"OK","type":"success"}}
In the preview part is like this:
body: [{mtr_codigo: 2586, aln_nome: "JOSÉ FERNANDO REIS", mtr_matricula: 201737909200976700}]
0: {mtr_codigo: 2586, aln_nome: "JOSÉ FERNANDO REIS", mtr_matricula: 201737909200976700}
aln_nome: "JOSÉ FERNANDO REIS"
mtr_codigo: 2586
mtr_matricula: 201737909200976700
meta: {output: []}
status: {code: 200, phrase: "OK", type: "success"}
EDIT 3:
In the method that delivers the result was with
json_encode($result, JSON_NUMBER_CHECK);
I removed this options parameter and returned the numeric value as string correctly.
I really could not reproduce this problem, here it works and arrives as string, are you using ajax? If yes, how is your ajax code and the exact php code that returns the json for this ajax?
– Gabriel Queiroz Schicora