0

I am using the json_encode to return an array from API to front end. Array contains some large size of keys and values with english and Spanish data. Here I have added the part of array.

Sometimes this json_encode returns empty and sometimes it returns correct data. I am facing this issue for same kind of array values.

what goes wrong with this json_encode?

Array(
[enable_view_map_button_caption] => 
[contact_practice_text] => 
[redirect_verification_page] => N
[enable_cc_on_file] => N
[cc_button_caption] => 
[cc_payment_button_url] => 
[display_completed_paperwok_page] => N
[enable_edit_paperwok] => N
[edit_paperwork_button_text] => Editar
[completed_paperwork_non_editable_page_text] => CompletÃÂÂÂÃÃ
)
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);

The array size will be very large, some keys will have more than 30K characters. Will it cause issue at server side?

Note: Here, I cant submit my actual array, due to StackOverflow text limitations.

James Z
  • 12,209
  • 10
  • 24
  • 44
ManiMuthuPandi
  • 1,594
  • 2
  • 26
  • 46
  • 1
    Regarding the size of your array, if some keys have more than 30K characters, it's possible that the size of the data may cause performance issues or memory usage problems on the server side. You may want to consider breaking down the data into smaller chunks or optimizing the data structure to reduce its size if possible. – Sarwar Ahmed Mar 17 '23 at 07:06
  • 1
    Empty output means wrong input. You have to verify that input is properly encoded UTF-8 – Your Common Sense Mar 17 '23 at 07:24

0 Answers0