Re: [Chicken-users] Returning JSON in Awful

2018-09-26 Thread Mario Domenech Goulart
Hi David,

On Wed, 26 Sep 2018 15:13:14 +1000 David Ireland  wrote:

> I've started using Awful 1.0 and having trouble returning a JSON string. The 
> inverted commas are being replaced by  For example, using
> the code below returns {a : 1 }
>
> Should this be normal behavior when returning JSON strings? 

Awful uses sxml-transforms behind the scenes to convert SXML to HTML,
and the sxml->html converter transforms `'' into `'.  You can
prevent that by using `(literal ,my-json) in your code.  Example:

(define-json (main-page-path)
  (λ ()
`(literal ,my-json)))

I see this is wrong in the documentation.  I'm gonna fix it.  Thanks for
reporting.

All the best.
Mario

> (use awful) 
> (enable-sxml #t) 
>
> (define my-json "{\"a\" : 1 }") 
>
> (define (define-json path body) 
> (define-page path 
> (λ () 
> (awful-response-headers '((content-type "text/json"))) 
> (body)) 
> no-template: #t)) 
>
> (define-json (main-page-path) 
> (λ () `(,my-json))) 
>
>
> ___
> Chicken-users mailing list
> Chicken-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
>

-- 
http://parenteses.org/mario

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Returning JSON in Awful

2018-09-25 Thread David Ireland
Hi,

I've started using Awful 1.0 and having trouble returning a JSON string.
The inverted commas are being replaced by  For example, using the
code below returns  {a : 1 }

Should this be normal behavior when returning JSON strings?

Thanks.
David

(use
awful)

(enable-sxml
#t)



(define my-json "{\"a\" : 1
}")


(define (define-json path
body)

  (define-page
path

(λ
()

  (awful-response-headers '((content-type
"text/json")))

(body))

no-template:
#t))



(define-json
(main-page-path)

  (λ ()
`(,my-json)))
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users