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

How to work with a JSON file?

plugins

Started by Deomid 4 years ago · 1 replies · 878 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 Vladimir Novak, 2 weeks ago
3 293 2 weeks ago
Plugins · by Mathieu Lecouturier, 3 weeks ago
3 277 3 weeks ago
Plugins · by Slebeig, 2 months ago
1 403 2 months ago
Plugins · by Rene, 2 months ago
2 574 2 months ago
Plugins · by Xavier, 3 months ago
2 490 3 months ago