2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-23 10:28:00 +00:00

12 Commits

Author SHA1 Message Date
Ben Pfaff
051a77d677 json: Remove write-only variable from json_lex_number(). 2010-08-25 14:55:47 -07:00
Ben Pfaff
597cf5a1c1 json: Better handle JSON objects with duplicate names.
RFC 4627 (which defines JSON) says:

    The names within an object SHOULD be unique.

In my view, this means that the treatment of duplicate names within a
JSON object is more or less up to the implementation.  Until now, the OVS
JSON parser has dealt with duplicates fairly badly: they all get shoved
into the hash table and you get one or the other value semi-randomly
(typically the one added later).  This commit makes the behavior
predictable: old values are deleted and replaced by newer values.
2010-06-30 16:49:01 -07:00
Ben Pfaff
4bda8288fb json: Fix typo in error message. 2010-03-03 09:55:01 -08:00
Ben Pfaff
d951f1c78c json: Fix memory leak when nesting depth is exceeded.
This is probably not an important memory leak, since it is only on a rare
error path, but it is best to fix it anyway.

Found with valgrind.
2010-02-02 15:21:09 -08:00
Ben Pfaff
36d802ae1f json: New function json_to_ds().
Some upcoming code wants to serialize JSON into a "struct ds" dynamic
string buffer, so expose an interface to do this.

This commit doesn't change much, but it renames some functions internal
to json.c to make the naming more consistent.

Also, make jsonrpc_log_msg() use this new function, since it is a more
straightforward way to do what it wants.
2010-01-26 09:49:30 -08:00
Ben Pfaff
7d23a63aa4 json: Export function to parse an individual JSON string.
The JSON syntax for strings is very reasonable.  An upcoming commit will
have a need for a string parser, so make the JSON string parser available
for that.

Also, this change improves the error message for strings that end in the
middle of a \u sequence, so update the tests to match.
2010-01-26 09:47:54 -08:00
Ben Pfaff
5562d6f55e test-json: Avoid use of /dev/stdin to fix builds in limited chroots.
The chroots in which we often build Open vSwitch don't have /proc and
thus cannot support /dev/stdin, because on Linux that is a symlink to
/proc/self/fd/0.  So avoid using /dev/stdin in the testsuite.
2009-12-17 15:50:01 -08:00
Ben Pfaff
a105c27b4e json: Accurately parse very large real numbers.
The test for whether a real number was outside the valid range was
imprecise and failed at the edge of the real range.  This commit changes
the code to use the C library's strtod(), which presumably does better.
2009-12-16 10:56:04 -08:00
Ben Pfaff
f6f8c3ba77 json: New convenience function json_array_create_1(). 2009-12-07 17:10:27 -08:00
Ben Pfaff
0bdf342a8c json: Improve error reporting. 2009-12-03 16:08:34 -08:00
Ben Pfaff
6e57173fab json: Make json_equal() compare objects correctly.
The previous code checked only that JSON objects have members with the
same names.  This commit makes json_equal() also check that like-named
members have the same values.
2009-11-06 12:26:22 -08:00
Ben Pfaff
f38b84ea2b Implement JSON parsing and serialization.
This will be used by the upcoming Open vSwitch configuration database.
2009-11-04 15:24:40 -08:00