I need to filter out from the array (namespaces) all values that do not fulfil the required condition: field 'status' = 'TRADING'
I use this variant
tmpSymbolsT←(data←⎕JSON(HttpCommand.Get'api.binance.com/api/v3/exchangeInfo').Data).symbols
tmpSymbols←{(⍵.status≡'TRADING')⌿⍵}⍨¨tmpSymbolsT
However, it returns every row in the wrapper, and I want clean rows
tmpSymbols[1] ⍝ I have
┌─────────────────────────────────┐
│┌───────────────────────────────┐│
││ #.[JSON object].[JSON object] ││
│└───────────────────────────────┘│
└─────────────────────────────────┘
tmpSymbolsT[1] ⍝ I need like this
#.[JSON object].[JSON object]
How to do it?
The problem here is that you filter each (
¨) object separately, rather than filtering the entire collection.(By the way, you also have an unnecessary commute (
⍨) which doesn't do anything in this context.)So, you really want something along the lines of
tmpSymbols←{(⍵.status≡'TRADING')⌿⍵}tmpSymbolsTbut now⍵.statusis a vector (list) of statuses, which of course won't match (≡) the single status'TRADING'. You have a few options for fixing this:⍵.status≡¨⊂'TRADING'uses an explicit each and encloses (⊂) the single status so it is used for every comparison.'TRADING'∘≡¨⍵.statusbinds (∘) the single status to the match function, thus deriving an "is trading" function, which is then applied to each status.⍵.status∊⊂'TRADING'which encloses the single status and checks all the statuses for which ones are a member of (∊) the array of a single status.Here is an example of code that does what you want: