Alaska Software Inc. - How to convert a dbf file to JSON
Username: Password:
AuthorTopic: How to convert a dbf file to JSON
Frits Janse KokHow to convert a dbf file to JSON
on Thu, 04 Jul 2019 16:44:54 +0200
I hope that someone has a code example to convert the data from a dbf 
file to a JSON string.  The dbf file also has memo fields.
Also the fieldnames need to be in the JSON string.

Kind regards
Frits Janse Kok



---
Deze e-mail is gecontroleerd op virussen door AVG.
http://www.avg.com
Tim CallahanRe: How to convert a dbf file to JSON
on Thu, 04 Jul 2019 15:50:37 -0700
On Thu, 04 Jul 2019 16:44:54 +0200, Frits Janse Kok wrote:

Does something like this work?

 Open JSON file

 Write JSON start

data->(dbgotop())
do while ! data->(eof())
   for i = 1 to data->(fcount())

       cFieldName := data->(fieldname(i))
       cValue        := data->(fieldget(i))

        Write JSON for field using cFieldName and cValue

   next
enddo

 write JSON end

 close JSON file

>I hope that someone has a code example to convert the data from a dbf 
>file to a JSON string.  The dbf file also has memo fields.
>Also the fieldnames need to be in the JSON string.
>
>Kind regards
>Frits Janse Kok
>
>
>
>---
>Deze e-mail is gecontroleerd op virussen door AVG.
>http://www.avg.com
Peter AlderliestenRe: How to convert a dbf file to JSON
on Sat, 06 Jul 2019 15:55:44 +0200
Tim Callahan wrote:

> data->(dbgotop())
> do while ! data->(eof())
>    for i = 1 to data->(fcount())
> 
>        cFieldName := data->(fieldname(i))
>        cValue        := data->(fieldget(i))
> 
>         Write JSON for field using cFieldName and cValue
> 
>    next
> enddo

or, as per latest Xbase++ build:

data->(dbgotop())
do while ! data->(eof())
    scatter name oData
    
   cJson := var2json(oData)
   write data

   data->(dbSkip())
enddo

Peter