Code Monkey home page Code Monkey logo

univalue's People

Contributors

btcdrak avatar fwolfst avatar isle2983 avatar jasonbcox avatar jgarzik avatar jmcorgan avatar jnewbery avatar jonasschnelli avatar karelbilek avatar kozyilmaz avatar laanwj avatar paveljanik avatar practicalswift avatar promag avatar ryanofsky avatar theuni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

univalue's Issues

does not install in /usr/lib

I downloaded univalue zip installed it as per instructions mentioned
But It does not install any files in /usr/lib or /usr/include which creates problem for installing cpptrade software.

Kindly help

Parser uses isspace, isdigit which are locale dependent

In my experience this can give interoperability issues which are very hard to troubleshoot if the user/application has a different locale setting.
I'd prefer using own implementations which strictly adhere to RFC4627 definitions.

  ws = *(
                %x20 /              ; Space
                %x09 /              ; Horizontal tab
                %x0A /              ; Line feed or New line
                %x0D                ; Carriage return
            )
digit1-9 = %x31-39         ; 1-9
zero = %x30                ; 0

Generates invalid JSON in case of special floating point values

No output at all is generated for special floating point values like NaN, -inf, +inf, resulting in unparseable output.

This is what python makes of it:

>>> json.dumps(float("inf"))                                                                                                                      
'Infinity'
>>> json.dumps(float("-inf"))
'-Infinity'
>>> json.dumps(float("-Nan"))                                                                                                                     
'NaN'

These are valid javascript, but not JSON according to https://tools.ietf.org/html/rfc7159:

   Numeric values that cannot be represented in the grammar below (such
   as Infinity and NaN) are not permitted.

Not sure how to handle this.

No support for wstring

Not sure if this was designed specifically for use with bitcoin related services only, but support for wstrings and other w* types would make it a great drop in replacement for the old json spirit many services just copied from pre-univalue sources.

Support move-semantics for UniValue

UniValue as a class could take advantage of C++11 move semantics to improve efficiency in some cases. (It is probably not very relevant in practice and for Bitcoin Core, but would still be nice to have.)

What do you think, would that make sense to add? (If yes, then I'm happy to provide a PR for it.)

Add documentation

Literally not a single method is documented :|

My main question is what is the difference between using the [] operator or find_value().

Parser accepts unseparated arrays

Commas (value-separator) between items in an array are mandatory according to RFC 4627, however univalue is somewhat lax. For example, this is accepted:

[ true true true [] [] [] ]

The same issue might exist for objects - haven't checked.

UTF-8 not handled while writing

UTF-8 is not handled while writing strings in json_escape. The result of this is that unicode sequences like '\u1234' will be expanded to their UTF-8 equivalent on a roundtrip, and re-encoded as multiple unicode characters \u00XX\u00XX... which is not correct.

This could be handled:

If the input/output is UTF-8 encoded, UTF-8 sequences in strings can be passed through on output without any processing (according to RFC 4627 "All Unicode characters may be placed within the quotation marks except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F).")

From RFC 4627:

JSON text SHALL be encoded in Unicode.  The default encoding is
UTF-8.

JSON value is not an object as expected

I sent this json {"jsonrpc":"2.0","method":"sendmany","params":["","{"test":9.5616}"],"id":2}

to program that use Univalue and got this error: "JSON value is not an object as expected"

Please issue new release 1.0.4

Hi,

It seems Bitcoin has run of with a recent development snapshot of univalue and treated it as release 1.0.4.

Please formally issue a release 1.0.4, for those (like Debian) who prefer system-shared libraries tracking single unified upstream projects.

(or document if in fact this is a fork and the proper source is what is maintained by the Bitcoin project).

Linking Error

/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
  CXX      test/object-object.o
  CXX      test/unitester-unitester.o
  CXX      test/no_nul-no_nul.o
  CXX      test/test_json-test_json.o
  CXX      lib/libunivalue_la-univalue.lo
  CXX      lib/libunivalue_la-univalue_get.lo
  CXX      lib/libunivalue_la-univalue_read.lo
  CXX      lib/libunivalue_la-univalue_write.lo
  CXXLD    libunivalue.la
ar: `u' modifier ignored since `D' is the default (see `U')
  CXXLD    test/object
  CXXLD    test/unitester
  CXXLD    test/no_nul
  CXXLD    test/test_json
ld: warning: ignoring file ./.libs/libunivalue.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file ./.libs/libunivalue.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file ./.libs/libunivalue.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture x86_64:
  "UniValue::read(char const*, unsigned long)", referenced from:
      _main in no_nul-no_nul.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Undefined symbols for architecture x86_64:
  "UniValue::push_backV(std::__1::vector<UniValue, std::__1::allocator<UniValue> > const&)", referenced from:
      univalue_array() in object-object.o
  "UniValue::read(char const*, unsigned long)", referenced from:
      univalue_typecheck() in object-object.o
      univalue_readwrite() in object-object.o
  "UniValue::clear()", referenced from:
      univalue_set() in object-object.o
      univalue_array() in object-object.o
      univalue_object() in object-object.o
  "UniValue::pushKV(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, UniValue const&)", referenced from:
      univalue_object() in object-object.o
  "UniValue::setInt(long long)", referenced from:
      univalue_set() in object-object.o
      univalue_object() in object-object.o
      UniValue::UniValue(long long) in object-object.o
      UniValue::UniValue(int) in object-object.o
  "UniValue::setInt(unsigned long long)", referenced from:
      univalue_set() in object-object.o
      UniValue::UniValue(unsigned long long) in object-object.o
  "UniValue::setStr(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      univalue_set() in object-object.o
      univalue_array() in object-object.o
      UniValue::UniValue(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in object-object.o
      UniValue::UniValue(char const*) in object-object.o
  "UniValue::pushKVs(UniValue const&)", referenced from:
      univalue_object() in object-object.o
  "UniValue::setBool(bool)", referenced from:
      univalue_typecheck() in object-object.o
      univalue_set() in object-object.o
      UniValue::UniValue(bool) in object-object.o
  "UniValue::setNull()", referenced from:
      univalue_set() in object-object.o
  "UniValue::__pushKV(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, UniValue const&)", referenced from:
      univalue_object() in object-object.o
  "UniValue::setArray()", referenced from:
      univalue_set() in object-object.o
  "UniValue::setFloat(double)", referenced from:
      univalue_set() in object-object.o
      UniValue::UniValue(double) in object-object.o
  "UniValue::push_back(UniValue const&)", referenced from:
      univalue_array() in object-object.o
make[1]: *** [test/no_nul] Error 1  "UniValue::setNumStr(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      univalue_constructor() in object-object.o
      univalue_typecheck() in object-object.o

      univalue_set() in object-object.o
  "UniValue::setObject()", referenced from:
      univalue_set() in object-object.o
      univalue_object() in object-object.o
make[1]: *** Waiting for unfinished jobs....
  "UniValue::checkObject(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, UniValue::VType, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, UniValue::VType> > > const&) const", referenced from:
Undefined symbols for architecture x86_64:
      univalue_object() in object-object.o
  "UniValue::read(char const*, unsigned long)", referenced from:
  "UniValue::write(unsigned int, unsigned int) const", referenced from:
      _main in test_json-test_json.o
      univalue_readwrite() in object-object.o
  "UniValue::write(unsigned int, unsigned int) const", referenced from:
      _main in test_json-test_json.o
  "UniValue::findKey(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long&) const", referenced from:
      univalue_object() in object-object.o
  "UniValue::getKeys() const", referenced from:
      univalue_typecheck() in object-object.o
  "UniValue::get_int() const", referenced from:
ld: symbol(s) not found for architecture x86_64
      univalue_typecheck() in object-object.o
  "UniValue::get_obj() const", referenced from:
      univalue_typecheck() in object-object.o
  "UniValue::get_str() const", referenced from:
      univalue_typecheck() in object-object.o
  "UniValue::get_bool() const", referenced from:
      univalue_typecheck() in object-object.o
  "UniValue::get_real() const", referenced from:
      univalue_typecheck() in object-object.o
  "UniValue::getObjMap(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, UniValue, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, UniValue> > >&) const", referenced from:
      univalue_object() in object-object.o
  "UniValue::getValues() const", referenced from:
      univalue_typecheck() in object-object.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  "UniValue::get_array() const", referenced from:
      univalue_typecheck() in object-object.o
  "UniValue::get_int64() const", referenced from:
      univalue_typecheck() in object-object.o
  "UniValue::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      univalue_object() in object-object.o
      univalue_readwrite() in object-object.o
  "UniValue::operator[](unsigned long) const", referenced from:
      univalue_array() in object-object.o
      univalue_readwrite() in object-object.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [test/test_json] Error 1
make[1]: *** [test/object] Error 1
ld: warning: ignoring file ./.libs/libunivalue.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture x86_64:
  "UniValue::read(char const*, unsigned long)", referenced from:
      unescape_unicode_test() in unitester-unitester.o
      _main in unitester-unitester.o
  "UniValue::write(unsigned int, unsigned int) const", referenced from:
      _main in unitester-unitester.o
  "UniValue::get_str() const", referenced from:
      unescape_unicode_test() in unitester-unitester.o
  "UniValue::operator[](unsigned long) const", referenced from:
      unescape_unicode_test() in unitester-unitester.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [test/unitester] Error 1
make: *** [all] Error 2

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.