Showing posts with label json. Show all posts
Showing posts with label json. Show all posts

Thursday, September 8, 2016

jq: command-line tool for parsing JSON.

Passing it through jq's parser, with the most basic option, will make it look nicer (with colors):
user@host:~$ curl -s https://status.github.com/api/status.json |\
  jq '.'
{
  "status": "good",
  "last_updated": "2015-01-21T16:59:01Z"
}
Do some basic selection:
user@host:~$ curl -s https://status.github.com/api/status.json |\
  jq '.status'
"good"

Wednesday, January 7, 2015

delimited data file ve json data file size kıyaslaması


Docs:
http://tools.ietf.org/html/rfc4627
http://www.ecma-international.org/publications/standards/Ecma-404.htm

Aşağıda detaylandırılan örnek; sıkıştırılmış delimited data file ve json data file dosya büyüklüğünü kıyaslamak,  format seçimi konusunda fikir edinmek amacı ile yapılmıştır.

 generator code:
<?php
$x=0;
$code=0;
$key=0;
for($i=0; $i<9000000; $i++) {
        $x++;
        $code++;
        $key++;
//      echo chr($i)."|";
//      echo $i."|";
        echo "{'key$key': '$i'},";
        if($x%10==0) echo "\n";
        if($key%10==0) $key=0;
        if($code=="255") $code=0;
}
?>




[root@okantest ~]# du -sh delimited.file.1
69M     delimited.file.1
[root@okantest ~]# wc -l delimited.file.1
900000 delimited.file.1
[root@okantest ~]# gzip delimited.file.1
[root@okantest ~]# du -sh delimited.file.1.gz
19M     delimited.file.1.gz


[root@okantest ~]# du -sh json.file.1
173M    json.file.1
[root@okantest ~]# wc -l json.file.1
900000 json.file.1
[root@okantest ~]# gzip json.file.1
[root@okantest ~]# du -sh json.file.1.gz
23M     json.file.1.gz