Giter Site home page Giter Site logo

Comments (9)

wthidden avatar wthidden commented on August 19, 2024

Further investigation has lead to a simpler case where encoding fails to encode correctly.
(custom/encode '('one 'two)) -> "[["/","/"],["/","/"]]"

as the json encoded string. I suspect symbol handling somewhere is the issue.

from cheshire.

dakrone avatar dakrone commented on August 19, 2024

Yea, I suspect the symbol handling is also to blame. I'll take a look at this.

from cheshire.

wthidden avatar wthidden commented on August 19, 2024

I think I know the issue after looking at the code.

The code assumes that the symbol will have been interned. In my case that
is not true, so resolve returns nil.

I think testing for symbol internment will be what is needed to resolve the
issue.

(William Hidden) https://sites.google.com/site/hiddenhome/

On Wed, Jan 11, 2012 at 12:52 PM, Lee <
[email protected]

wrote:

Yea, I suspect the symbol handling is also to blame. I'll take a look at
this.


Reply to this email directly or view it on GitHub:
#13 (comment)

from cheshire.

wthidden avatar wthidden commented on August 19, 2024

Lee,

Here's how I patched encode-symbol to get what I needed. Not sure if it
complies with what you were looking for:

diff --git a/src/cheshire/custom.clj b/src/cheshire/custom.clj
index 399ca63..cccbad7 100644
--- a/src/cheshire/custom.clj
+++ b/src/cheshire/custom.clj
@@ -126,9 +126,11 @@
"Encode a clojure symbol to the json generator. Symbols will be encoded
as
/"
[^clojure.lang.Symbol s ^JsonGenerator jg]

  • (.writeString jg (str (:ns (meta (resolve s)))
  •                    "/"
    
  •                    (:name (meta (resolve s))))))
    
  • (if (resolve s)
  • (.writeString jg (str (:ns (meta (resolve s)))
  •                      "/"
    
  •                      (:name (meta (resolve s)))))
    
  • (.writeString jg (name s))))

;; extended implementations for clojure datastructures
(extend nil

(William Hidden) https://sites.google.com/site/hiddenhome/

On Wed, Jan 11, 2012 at 2:16 PM, William Hidden [email protected]:

I think I know the issue after looking at the code.

The code assumes that the symbol will have been interned. In my case that
is not true, so resolve returns nil.

I think testing for symbol internment will be what is needed to resolve
the issue.

(William Hidden) https://sites.google.com/site/hiddenhome/

On Wed, Jan 11, 2012 at 12:52 PM, Lee <
[email protected]

wrote:

Yea, I suspect the symbol handling is also to blame. I'll take a look at
this.


Reply to this email directly or view it on GitHub:
#13 (comment)

from cheshire.

dakrone avatar dakrone commented on August 19, 2024

I just pushed a fix for this in eaee529, can you give it a shot and see if it works for all your use cases?

from cheshire.

wthidden avatar wthidden commented on August 19, 2024

Yes... works for me, thanks.

(William Hidden) https://sites.google.com/site/hiddenhome/

On Wed, Jan 11, 2012 at 6:21 PM, Lee <
[email protected]

wrote:

I just pushed a fix for this in eaee529, can you give it a shot and see if
it works for all your use cases?


Reply to this email directly or view it on GitHub:
#13 (comment)

from cheshire.

dakrone avatar dakrone commented on August 19, 2024

Cool, I'll push a new version out with this fix.

from cheshire.

dakrone avatar dakrone commented on August 19, 2024

Fixed in 2.0.5

from cheshire.

wthidden avatar wthidden commented on August 19, 2024

Thank you for putting together the Cheshire library it is exactly what I
needed!

(William Hidden) https://sites.google.com/site/hiddenhome/

On Wed, Jan 11, 2012 at 6:34 PM, Lee <
[email protected]

wrote:

Fixed in 2.0.5


Reply to this email directly or view it on GitHub:
#13 (comment)

from cheshire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.