Giter VIP home page Giter VIP logo

jscon's Introduction

jscon's People

Contributors

lcsmuller avatar papaulogamerofc avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

stensalweb

jscon's Issues

`fcvt` is not thread-safe. Should it be replaced with sprintf?

The following is the quote from the manual of fcvt.

Both the ecvt() and fcvt() functions return a pointer to a static string containing the ASCII representation of number. The static string is overwritten by each call to ecvt() or fcvt().
Conforming To

SVr2; marked as LEGACY in POSIX.1-2001. POSIX.1-2008 removes the specifications of ecvt() and fcvt(), recommending the use of sprintf(3) instead (though snprintf(3) may be preferable).

is test data missing?

I want to run the code under test folder, but it seems there is no test data. It would be great if some sample test data is checked in.

using "%s[discord][token]"

str is

{
   "discord": {
      "token": "XXX"
   },
   "logging": {
      "filename": "YYY",
      "level": debug
   }
}
jscon_scanf(str,
              "%s[discord][token] %s[logging][filename] %s[logging][level]",
              settings->discord.token,
              settings->logging.filename, 
              settings->logging.level);

Does this work?

allow specifying the maximum size of strings to be read

scanf example:

 char string[3];
 scanf("%3s", string);

scanf can be limited with how many characters to be read from the input string by format specifier like %3s. If json_scanf has this feature, we can convert many internal fields of discord-public-user.c to static arrays without worrying about buffer overruns.

free a null pointer

file:/jscon-parser.c::105, 5
free(item->key); // item->key can be null.

While this is ok by C standard, the mismatching of malloc/free invoked at runtime could makes debugging memory leak harder.

deserialize nested json objects with json_scanf

json_scanf is very clever. But If I have a nested json object, can I still use json_scanf?

For example, given the following string

"{
   'project-configurations': 
   [
        { 'name':  'p1',   'build': 'b1' },
        { 'name':  'p2',   'build': 'b2' }
   ]
}"

Can I still use json_scanf to de-serialize it?

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.