3
I have the following JSON (complete):
{
"name": "Romano Pesca",
"count": 8,
"frequency": "Weekly",
"version": 5,
"newdata": false,
"lastrunstatus": "success",
"thisversionstatus": "success",
"nextrun": "Sat Aug 08 2015 15:14:57 GMT+0000 (UTC)",
"thisversionrun": "Sat Aug 01 2015 15:14:57 GMT+0000 (UTC)",
"results": {
"collection1": [
{
"img": {
"alt": "Vara Sumax Victória 9'0\" ( 2,70m ) Para Carretilha",
"href": "http://www.romanopesca.com.br/vara-sumax-victoria-9-0-2-70m-para-carretilha.php",
"src": "http://www.romanopesca.com.br/media/catalog/product/cache/1/small_image/135x/9df78eab33525d08d6e5fb8d27136e95/s/u/sumax-080357_1.jpg",
"text": ""
},
"prod": {
"href": "http://www.romanopesca.com.br/vara-sumax-victoria-9-0-2-70m-para-carretilha.php",
"text": "Vara Sumax Victória 9'0\" ( 2,70m ) Para Carretilha"
},
"valor": "R$242,91",
"index": 1,
"url": "http://www.romanopesca.com.br/"
},
I need to put the values inside the "Prod" -> "text" keys in uppercase letter.
"results": {
"collection1": [
{
"prod": {
"text": "ARA SUMAX VICTÓRIA 9'0" ( 2,70M ) PARA CARRETILHA"
},
I have the following code, for php cases:
<?php
$request ="https://www.kimonolabs.com/api/7fzc196k?apikey=9TCUO9EskMyL4HtmqHMNDIiaZ9KmOcXn";
$response = file_get_contents($request);
$results = json_decode($response, TRUE);
array_walk_recursive($results, function ($value)
{
$value = mb_strtoupper($value, 'UTF-8');
});
$meu_json_tudo_maiusculo = json_encode($results);
?>
I also thought of using a function in javascript, instead of php, to change the result of JSON, leaving it uppercase.
So far the above code is not working.
vc want the array keys in upper case or only the value?
– rray
only the value, @rray
– GustavoCave
You only need to present these values in uppercase on a web page?
– user6476
@rocmartins no, I need to turn the JSON into uppercase. It is for the purpose of searching on the site.
– GustavoCave
In this case, I believe the most correct approach is to make a search that is case insensitive.
– user6476
@rocmartins has some material to send me?
– GustavoCave
I got it using stristr instead of strto. Was asism: if(stristr($Collection['Prod']['text'],$string) !== false) { echo...
– GustavoCave
@Gustavocave depends a lot on how you are doing the search. I don’t understand what the search structure is and what you need JSON for.
– user6476
Your JSON is still wrong! Missing the closure with
]
and}
– Wallace Maxters