Giter Club home page Giter Club logo

Comments (3)

ibireme avatar ibireme commented on August 29, 2024 1

I wanted yyjson_get_xxx functions to return a default value (usually 0/NULL) on error. I get your point, but Iā€™m not sure what most C developers would like from these functions. I checked some popular C JSON libraries and saw that cJSON returns NaN, while json-c, jansson, and parson all return 0. So I think returning 0 might be a better choice as it seems more common.

from yyjson.

ibireme avatar ibireme commented on August 29, 2024

Thanks for pointing out, I will remove the extra space later.

yyjson_get_num returns NaN is more reasonable indeed. But here it returns 0 just to be consistent with other functions like yyjson_get_int/yyjson_get_real/ā€¦

from yyjson.

pavelxdd avatar pavelxdd commented on August 29, 2024

That's a good point. Howewer, as I see it, yyjson_get_num is a high-level function over the yyjson_get_int/yyjson_get_real/ā€¦ and does the conversions and returns only doubles, and NaN is perfect fit to indicate something is not a number in a world of doubles.

It's not a big deal anyway, considering that the type of value can always be checked for number manually prior to calling yyjson_get_num.

from yyjson.

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.