how to write code that parse my json that I got with webrequest - page 3

 

Sir thank for your all supports 

But I need to give you question 

solved the json problem I wrote code with python then wrote the json codes to my target file Now, I try to get the latest data from the file how can I do this?

 
Caner Efe Altıntaş #:

Sir thank for your all supports 

But I need to give you question 

solved the json problem I wrote code with python then wrote the json codes to my target file Now, I try to get the latest data from the file how can I do this?

Excellent .

How does the file look ? its an array ?

 

This is how my data file looks like 

Files:
parse.png  159 kb
 
Caner Efe Altıntaş #:

This is how my data file looks like 

awesome . I think theres two brackets missing there , one on the start and one at the end . 

Send it as source code with the </> button on top and i'll whip up an example 

 

Sir do you mean like this


{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 12:25:02'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30270, Volume = {{144.7899}}', 'created_at': '2023-07-09 12:24:41'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 12:19:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30274, Volume = {{144.7899}}', 'created_at': '2023-07-09 12:09:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30280, Volume = {{144.7899}}', 'created_at': '2023-07-09 12:05:02'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 12:04:07'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 12:00:37'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30281, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:52:03'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:46:02'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30277, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:39:36'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30278, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:32:24'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:30:14'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30288, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:26:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:22:04'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:15:03'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30263, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:11:04'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30267, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:07:58'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30274, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:04:56'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30277, Volume = {{144.7899}}', 'created_at': '2023-07-09 11:00:21'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:56:10'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30300, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:43:06'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:41:12'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30286, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:40:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:31:42'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30269, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:29:15'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:23:14'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30277, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:15:17'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:13:51'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30287, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:08:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:04:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 10:00:52'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:58:22'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30280, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:56:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:49:22'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30270, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:48:36'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30269, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:42:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:37:13'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30257, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:34:44'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:29:58'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30285, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:28:06'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:24:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30286, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:21:24'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:19:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30284, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:12:25'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:11:03'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30288, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:11:03'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30299, Volume = {{144.7899}}', 'created_at': '2023-07-09 09:02:01'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 08:58:00'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = 30300, Volume = {{144.7899}}', 'created_at': '2023-07-09 08:56:11'}
{'method': 'POST', 'content': 'BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}', 'created_at': '2023-07-09 08:48:24'}
 
Caner Efe Altıntaş #:

Sir do you mean like this


Yes sir , you see this in your server right ?

 
Yes, I am seeing right now.
 
Caner Efe Altıntaş #:

Sir do you mean like this


Your JSON format is not correct. If this code is generated by something you have control to, you should fix it. Use a JSON validator to check it (there are plenty online).
 

As Alain said your format must be something like this :

[{"method": "POST", "content": {"Symbol":"BITSTAMP:USDJPY","Direction":1,"Price":0.0000,"Volume":144.7899}, "created_at": "2023-07-09 12:25:02"},
{"method": "POST", "content": {"Symbol":"BITSTAMP:USDJPY","Direction":0,"Price":0.0000,"Volume":143.7899}, "created_at": "2023-07-09 12:20:02"}]

The content sent by trading view ,you will also need the direction of the signal to be sent.

This may also help

https://www.w3schools.com/js/js_json_intro.asp

JSON Introduction
JSON Introduction
  • www.w3schools.com
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
 

Thank you for your attention I think I did it did you mean that ?

I checked from online json validator It says valid 



   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30277, Volume = {{144.7899}}",
      "created_at":"2023-07-09 11:00:21"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 10:56:10"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30300, Volume = {{144.7899}}",
      "created_at":"2023-07-09 10:43:06"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 10:41:12"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30286, Volume = {{144.7899}}",
      "created_at":"2023-07-09 10:40:00"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 10:31:42"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30269, Volume = {{144.7899}}",
      "created_at":"2023-07-09 10:29:15"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 10:23:14"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30277, Volume = {{144.7899}}",
      "created_at":"2023-07-09 10:15:17"
   }
]