Vous n'avez pas assez d'informations pour nous pour vous aider. Mais si vous deviez intégrer/fusionner du contenu en JSON, utilisez $ http.post(). Un exemple:
// Some data to send
var my_data = {"widgets":[{"widget1":""},{"widget2":""},{"widget3":""}],"JSONfile":"file.json"};
$http.post(url,my_data).then(function(result){
/* Success */
}, function(error){
/* Error */
});
Pour ouvrir et modifier JSON vous pouvez utiliser PHP:
<?php
/* Get the data from POST request
$dataReceived = file_get_contents('php://input');
$myFile = json_decode($dataReceived);
$myWidget = $myFile->widgets;
$JSON_file_name = $myFile->JSONfile;
*/
$content = json_decode(file_get_contents($JSON_file_name), true);
$content['content'][] = ['widget'=>$myWidget];
$newJsonString = json_encode($content, JSON_UNESCAPED_SLASHES);
file_put_contents($JSON_file_name, $newJsonString);
?>
Pour récupérer les données de JSON:
$http.get(url).then(function(result){
$scope.my_data = result.data;
}, function(error){
/* Error */
$scope.my_data = null;
});
merci, maintenant j'undertand tout – MargeKh