JSON output from ubreport

ubreport can easily produce JSON output – it is after all just a format. However there are some caveats.

If you just write a simple report:

: names

K name

H
[
>

F
]
>

R
"name": "[name]",
>

You will get something like:

[
"name":"fred",
"name":"jane",
]

The problem here is the final “,” (“jane”,). This will break many JSON parsers.

To fix this we add an N section:

: names

K name

H
[
>

F
]
>

N [name]
,
>

R
"name": "[name]"
>

Now you will get something like:

[
"name":"fred"
,
"name":"jane"
]

Which is legal JSON.