Changeset 1354 for fmts/trunk/p


Ignore:
Timestamp:
Feb 1, 2012, 12:50:16 AM (13 years ago)
Author:
George Lilly
Message:

experimenting with json out

Location:
fmts/trunk/p
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fmts/trunk/p/C0XF2N.m

    r1349 r1354  
    4141 S @ZFARY@("BLKLOAD")=1 ; this file supports block load
    4242 S @ZFARY@("FMTSSTYLE")="F2N" ; fileman style
     43 S @ZFARY@("REPLYFMT")="JSON"
    4344 D USEFARY(ZFARY)
    4445 Q
  • fmts/trunk/p/C0XGET1.m

    r1351 r1354  
    114114 W !,"s:",zsub," p:",zpred," o:",zobj
    115115 d trip(.tmprtn,zsub,zpred,zobj,zgraph,fary)
    116  n zzz,zrsub,zrpred,zrobj,zgraph,zcnt
    117  s zcnt=1
     116 n zzz,zrsub,zrpred,zrobj,zgraph,zcnt,zrary
    118117 s zzz=""
    119118 f  s zzz=$o(tmprtn(zzz)) q:zzz=""  d  ;
     
    122121 . s zrobj=$$GET1^DIQ(C0XTFN,zzz_",",.05,"E")
    123122 . s zrgraph=$$GET1^DIQ(C0XTFN,zzz_",",.02,"E")
    124  . s triplertn(zcnt)=zrsub_"^"_zrpred_"^"_zrobj ; _"^"_zrgraph
    125  . s zcnt=zcnt+1
     123 . s zrary(zrsub,zrpred_"^"_zrobj)=""
     124 ;b
     125 ;
     126 i REPLYFMT="JSON" d jsonout(.triplertn,.zrary) q  ; what follows is 'else'
     127 ;
     128 ; if no reply format is found we just output an array of triples
     129 ;
     130 s zrsub=""
     131 s zcnt=1
     132 f  s zrsub=$o(zrary(zrsub)) q:zrsub=""  d  ; organized by subject
     133 . s zzz=""
     134 . f  s zzz=$o(zrary(zrsub,zzz)) q:zzz=""  d  ; pred and obj
     135 . . s triplertn(zcnt)=zrsub_"^"_zzz
     136 . . s zcnt=zcnt+1
     137 q
     138 ;
     139jsonout(jout,zary) ;
     140 d REPLYSTART^FMQLJSON("jout")
     141 d LISTSTART^FMQLJSON("jout","results")
     142 n zi s zi=""
     143 f  s zi=$o(zary(zi)) q:zi=""  d  ; for each subject
     144 . n zii s zii=""
     145 . D DICTSTART^FMQLJSON("jout",zi)
     146 . f  s zii=$o(zary(zi,zii)) q:zii=""  d  ; for each pred^obj pair
     147 . . d DASSERT^FMQLJSON("jout",$p(zii,"^",1),$p(zii,"^",2))
     148 . D DICTEND^FMQLJSON("jout")
     149 d LISTEND^FMQLJSON("jout")
     150 d REPLYEND^FMQLJSON("jout")
    126151 q
    127152 ;
Note: See TracChangeset for help on using the changeset viewer.