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

 
Caner Efe Altıntaş #:

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

I checked from online json validator It says valid 



It's maybe valid but you will not be able to parse it as you like, because this is monolithic.

"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}"

Look at Lorentzos example above.

 
Okay can you explain more detail? how can I parse as I want? what is the monolithic? 
 
Caner Efe Altıntaş #:
Okay can you explain more detail? how can I parse as I want? what is the monolithic? 

For instance , how did you code the symbol return in the trading view alert ?

If you can remove the brackets , that would be the first step as it is my understanding that the symbol is "BITSTAMP:USDJPY"

BITSTAMP:{{USDJPY}}
 
[
   {
      "method":"POST",
      "content":"BITSTAMP:BTCUSD, Price = 30374, Volume = 0.01846",
      "created_at":"2023-07-09 15:08:20"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:BTCUSD, Price = 30357, Volume = 0.07803042",
      "created_at":"2023-07-09 15:05:20"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:BTCUSD, Price = 30335, Volume = 0.36356433",
      "created_at":"2023-07-09 15:04:36"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:BTCUSD, Price = 30344, Volume = 0.00626",
      "created_at":"2023-07-09 15:01:20"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30350, Volume = {{144.7899}}",
      "created_at":"2023-07-09 15:00:18"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:BTCUSD, Price = 30343, Volume = 0.04026222",
      "created_at":"2023-07-09 14:53:27"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30331, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:50:32"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:46:26"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30364, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:39:08"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:24:49"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30221, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:23:00"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:20:01"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30218, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:18:00"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:11:50"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30259, Volume = {{144.7899}}",
      "created_at":"2023-07-09 14:01:01"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:57:00"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{USDJPY}, LS = {long}, Volume = 2023-07-09T13:30:00Z",
      "created_at":"2023-07-09 13:53:03"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30310, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:46:37"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:44:59"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30306, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:42:02"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:39:03"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30310, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:37:48"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30318, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:33:09"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:32:42"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:30:27"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30317, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:25:08"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30356, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:11:33"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:06:14"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30338, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:04:49"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30342, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:00:12"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 13:00:12"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30335, Volume = {{144.7899}}",
      "created_at":"2023-07-09 12:59:14"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30336, Volume = {{144.7899}}",
      "created_at":"2023-07-09 12:55:34"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 12:47:32"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30309, Volume = {{144.7899}}",
      "created_at":"2023-07-09 12:43:40"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}",
      "created_at":"2023-07-09 12:40:00"
   },
   {
      "method":"POST",
      "content":"BITSTAMP:{{USDJPY}}, Price = 30315, Volume = {{144.7899}}",
      "created_at":"2023-07-09 12:37:16"
   },
   {
      "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"
   }
]
 
Okay now I fixed that you mentioned now how my json codes look like is it ready for parsing from mql4?
 
Caner Efe Altıntaş #:

i'll explain it a bit better

"content" is an object that contains 

BITSTAMP:{{USDJPY}}, Price = 30278, Volume = {{144.7899}}

you will be able to ask for ["content"] but you wont be able to ask for ["content"]["price"] or ["content"]["volume"] this way.

You would need to do additional ninja stuff but if you format it right from the beggining you are good to go

 
Caner Efe Altıntaş #:
Okay can you explain more detail? how can I parse as I want? what is the monolithic? 

You need a valid JSON and a "field" for each value.

"BITSTAMP:{{USDJPY}}, Price = {{buy}}, Volume = {{144.7899}}"

Monolithic means a parser will consider this as 1 value due to the quotessurrounded the whole, and will not parse what is inside.

Please learn about JSON, Lorentzos gave you the link. It's beyond the purpose of this forum to explain that in details here.

This line should simply be something like :

         "content": {"symbol": "USDJPY", "Price": 30286, "Volume": 144.7899},
 
Lorentzos Roussos #:

i'll explain it a bit better

"content" is an object that contains 

you will be able to ask for ["content"] but you wont be able to ask for ["content"]["price"] or ["content"]["volume"] this way.

You would need to do additional ninja stuff but if you format it right from the beggining you are good to go

He needs to understand to JSON format to start with, otherwise it's waste of time. I will let you continue if you like.
 
Alain Verleyen #:
He needs to understand to JSON format to start with, otherwise it's waste of time. I will let you continue if you like.

Yeah , he kinda does because the {{USDJPY}} indicates he is trying to alter the alert from trading view , if i'm not mistaken .

It could also be the bitstamp api though . 
 
Lorentzos Roussos #:

As Alain said your format must be something like this :

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

hey guys as you told I solved the content part in the json is there anything wrong? Let it check please.



[
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 0,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:36:35"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 1,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:31:00"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 0,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:29:11"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 1,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:27:14"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 0,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:26:13"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 0,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:21:10"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 1,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:18:07"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 0,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:15:13"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 1,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:13:10"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 0,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:08:01"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 1,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:06:17"
    },
    {
        "method": "POST",
        "content": {
            "Symbol": "BITSTAMP:USDJPY",
            "Direction": 0,
            "Price": 0.0,
            "Volume": 143.7899
        },
        "created_at": "2023-07-09 19:01:42"
    },
]
Reason: