Hello, I’m using q to access a REST API returning json data structures:
q)\l json.kq)v:system "curl -k -H \"Authorization: Bearer MyToken\" https://api-fxpractice.oanda.com/v1/accounts" % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 369 100 369 0 0 253 0 0:00:01 0:00:01 --:--:-- 253q)v,"{""\t\"accounts\" : [""\t\t{""\t\t\t\"accountId\" : 1125870,""\t\t\t\"accountName\" : \"Primary\",""\t\t\t\"accountCurrency\" : \"EUR\",""\t\t\t\"marginRate\" : 0.05""\t\t},""\t\t{""\t\t\t\"accountId\" : 9244246,""\t\t\t\"accountName\" : \"Bull\",""\t\t\t\"accountCurrency\" : \"EUR\",""\t\t\t\"marginRate\" : 0.02""\t\t},""\t\t{""\t\t\t\"accountId\" : 6955195,""\t\t\t\"accountName\" : \"Bear\",""\t\t\t\"accountCurrency\" : \"EUR\",""\t\t\t\"marginRate\" : 0.02""\t\t}""\t]","}"
But I don’t know how to use json.k to parse this data:
q).j.k vk){=\~("\\"=-1_q,x)<q=x}'length<(0b;,0b;000000000000000b;000b;0000000000000000000000000b;00000000000000000000..(,0b;010000000010000b;000b;0001000000000100000000000b;00010000000000010001000..q.j))
Please, can you help me?
Cheers
Francisco
felix1
3
The latest kdb has the json parser built in.
Look in the .j namespace for utility functions.
Pe 08.09.2014 08:07, “Francisco” <frangonve@gmail.com> a scris:
Hello, I’m using q to access a REST API returning json data structures:
q)\l json.kq)v:system "curl -k -H \"Authorization: Bearer MyToken\" https://api-fxpractice.oanda.com/v1/accounts" % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 369 100 369 0 0 253 0 0:00:01 0:00:01 --:--:-- 253q)v,"{""\t\"accounts\" : [""\t\t{""\t\t\t\"accountId\" : 1125870,""\t\t\t\"accountName\" : \"Primary\",""\t\t\t\"accountCurrency\" : \"EUR\",""\t\t\t\"marginRate\" : 0.05""\t\t},""\t\t{""\t\t\t\"accountId\" : 9244246,""\t\t\t\"accountName\" : \"Bull\",""\t\t\t\"accountCurrency\" : \"EUR\",""\t\t\t\"marginRate\" : 0.02""\t\t},""\t\t{""\t\t\t\"accountId\" : 6955195,""\t\t\t\"accountName\" : \"Bear\",""\t\t\t\"accountCurrency\" : \"EUR\",""\t\t\t\"marginRate\" : 0.02""\t\t}""\t]","}"
But I don’t know how to use json.k to parse this data:
q).j.k vk){=\~("\\"=-1_q,x)<q=x}'length<(0b;,0b;000000000000000b;000b;0000000000000000000000000b;00000000000000000000..(,0b;010000000010000b;000b;0001000000000100000000000b;00010000000000010001000..q.j))
Please, can you help me?
Cheers
Francisco
–
Submitted via Google Groups
It does?
KDB+ 3.1 2014.08.22 Copyright (C) 1993-2014 Kx Systems
l32/ 4()core 15748MB j m5 127.0.1.1 NONEXPIRE
q)key `.j
q)
sohagan
5
From v3.2 2014.08.22 …not sure when the 3.2 free version is being released.
http://code.kx.com/wiki/Cookbook/Websocket#JSON