Code Monkey home page Code Monkey logo

Comments (9)

tasdikrahman avatar tasdikrahman commented on May 25, 2024

Hey @gdude2002 , I understand your concern and I think there should be an option like json=False added.

Consider this to be added in the next release 👍

from vocabulary.

gdude2002 avatar gdude2002 commented on May 25, 2024

👍

EDIT: @prodicus Just out of interest, why did you decide to do it this way?

from vocabulary.

tasdikrahman avatar tasdikrahman commented on May 25, 2024

So what if(that's a big if) someone would be using this in javascript and wanted to access the list being returned? Now I am not sure if you can inherently do that in javascript but I thought returning JSON objects would pretty much serve the purpose of delivering the data in a widely usable manner. Leave alone for javascript.

Now I may be wrong on this, so it would be great if you could share your thoughts on this

Edit Is this appropriate ? http://stackoverflow.com/questions/23038710/accessing-python-list-in-javascript-as-an-array

from vocabulary.

gdude2002 avatar gdude2002 commented on May 25, 2024

Well, sure, but you're writing a Python library here, not a JavaScript library. What use case do you have for this Python-bound data somehow ending up being used by a JavaScript program, and why can't that program request the data on its own?

Besides, if you are doing that, you can convert it back to JSON when you need it to be JSON.

from vocabulary.

tasdikrahman avatar tasdikrahman commented on May 25, 2024

You have a point here @gdude2002 . So would returning a list be a good idea? Or a dict?

Edit How would you suggest structuring the data to be returned?

from vocabulary.

gdude2002 avatar gdude2002 commented on May 25, 2024

Whichever would be more appropriate for the data you're returning, yes. Most (valid) JSON data will translate directly to Python dicts, but there's no reason you can't clean them up a little before returning if you so wish.

from vocabulary.

tasdikrahman avatar tasdikrahman commented on May 25, 2024

I feel that list's would be good here (wordnet style).

So instead of

>>> vb.meaning("levitate")
'[{"text": "(intransitive) Be suspended in the air, as if in defiance of gravity.", "seq": 0}, {"text": "(transitive) To cause to rise in the air and float, as if in defiance of gravity.", "seq": 1}]'
>>>

it would return

>>> vb.meaning("levitate")
["(intransitive) Be suspended in the air, as if in defiance of gravity.",  "(transitive) To cause to rise in the air and float, as if in defiance of gravity."]
>>>

when json=False

What do you think ?

from vocabulary.

gdude2002 avatar gdude2002 commented on May 25, 2024

Yeah, that makes sense to me.

from vocabulary.

tasdikrahman avatar tasdikrahman commented on May 25, 2024

Closed by 7573f21.

feel free to reopen it again if not the case @gdude2002

from vocabulary.

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.