Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

How to work with a JSON file?

plugins

Started by Deomid 4 years ago · 1 replies · 751 views
4 years ago

Hello everyone I wish you all the best. Please help me if there is someone more experienced than me here.

I am trying to implement functionality so that my plugin can write data to a JSON file that the user will send an asynchronous request.

I need to store a JSON file in cms files. I need to write a plugin that will accept an asynchronous request with a new JSON file, and update the JSON file on the server.

  1. Where do I store the JSON file?
  2. What code do I need to write in my plugin to get the contents of the JSON file?
  3. What code do I need to write in my plugin to edit the JSON file?

I'm sorry if I made grammatical mistakes, my knowledge of English is not at the highest level.

4 years ago

hi @FedorovDeomid ,
my recommendation is, just search for an existing plugin that deals with JSON files and see how this can be handeled.
then you can derive the code you need for your application from the example (at least you can see hoe to read/write/update data in JSON files).
a simple example is my ipcount plugin which counts website hits and stores the count data in a JSON file.

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 54 1 week ago
Plugins · by Xavier, 4 weeks ago
2 61 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1188 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 54 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 79 2 months ago