Python Forum
Error string indice must integers Json
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error string indice must integers Json
#1
I have a problem with my code

response = requests.get("http://www.testecliente.com.br/ApiTeste/GetDadosCartaoCliente?CL_COD=1" )
retorno = response.content
retorno = retorno.decode("utf-8")
json_data = json.loads(retorno)
CL_NOME = json_data['CL_NOME']
print ("NOME=" + CL_NOME)

When I try to run the following error occurs :

CL_NOME = json_data['CL_NOME']
TypeError : string indices must be integers


if I send print json_data appears:

{"CC_COD":16,"CL_COD":40,"CC_NUMERO_CARTAO":"68453217628884","CC_BANDEIRA":"visa","CC_VALIDADE":"09/21","CC_COD_SEGURANCA":"188","CC_FUNCAO":"C","CC_PRINCIPAL":"S","CL_NOME":"Alexandre Luiz"}

if I print the type the result is:
print (type(json_data))

result --> <class 'str'>


Can someone help me ?
Reply


Messages In This Thread
Error string indice must integers Json - by ALEGON - Jan-10-2018, 10:11 AM
RE: Error string indice must integers Json - by mpd - Jan-10-2018, 02:38 PM
RE: Error string indice must integers Json - by mpd - Jan-10-2018, 05:14 PM
RE: Error string indice must integers Json - by mpd - Jan-10-2018, 06:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  json loads throwing error mpsameer 8 775 Jan-23-2024, 07:04 AM
Last Post: deanhystad
  boto3 - Error - TypeError: string indices must be integers kpatil 7 1,339 Jun-09-2023, 06:56 PM
Last Post: kpatil
  [split] Parse Nested JSON String in Python mmm07 4 1,604 Mar-28-2023, 06:07 PM
Last Post: snippsat
  Response.json list indices must be integers or slices, not str [SOLVED] AlphaInc 4 6,528 Mar-24-2023, 08:34 AM
Last Post: fullytotal
  json decoding error deneme2 10 3,863 Mar-22-2023, 10:44 PM
Last Post: deanhystad
  "TypeError: string indices must be integers, not 'str'" while not using any indices bul1t 2 2,088 Feb-11-2023, 07:03 PM
Last Post: deanhystad
  Error "list indices must be integers or slices, not str" dee 2 1,509 Dec-30-2022, 05:38 PM
Last Post: dee
  python requests library .JSON() error mHosseinDS86 6 3,535 Dec-19-2022, 08:28 PM
Last Post: deanhystad
  Read nested data from JSON - Getting an error marlonbown 5 1,438 Nov-23-2022, 03:51 PM
Last Post: snippsat
  TypeError: string indices must be integers JonWayn 12 3,529 Aug-31-2022, 03:29 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020