I have a py file to read data from WordPress API and pass values to another fields of other API. When values are singles, i have no problem, but i don’t know how make that:
When i read one field from the API, the states values, comes with code instead the text value. For example, when the text value in WordPress is Barcelona, returns B, and i’ll need that the value returned will be Barcelona.
One example of code with simple fields values:
oClienteT["Direcciones"] = []
oClienteT["Telefono"] = oClienteW["billing"]["phone"]
oClienteT["NombreFiscal"] = oClienteW["first_name"] " " oClienteW["last_name"]
oClienteT["Direcciones"].append( {
"Codigo" : oClienteW["id"],
"Nombre" : oClienteW["billing"]["first_name"],
"Apellidos" : oClienteW["billing"]["last_name"],
"Direccion" : oClienteW["billing"]["address_1"],
"Direccion2" : oClienteW["billing"]["address_2"],
"Poblacion" : oClienteW["billing"]["state"],
"Provincia" : oClienteW["billing"]["city"]
})
When billing city is Madrid and billing state is madrid, WordPress returns Madrid and M
I need tell thst when Madrid, returns Madrid, and so on.
2
Answers
I've just got solved it:
Make sure to convert to a JSON object before accessing fields
(data = json.loads(json_str))