Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

How to work with a JSON file?

plugins

Started by Deomid 4 years ago · 1 replies · 944 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 renedebaaij, 2 days ago
0 39 2 days ago
Plugins · by complanar, 3 weeks ago
6 392 2 weeks ago
Plugins · by BenLaKnet, 2 weeks ago
1 209 2 weeks ago
Plugins · by complanar, 1 month ago
2 484 4 weeks ago
Plugins · by Vladimir Novak, 2 months ago
3 763 2 months ago