-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
small experiment with cJSON #833
Conversation
Grab current master (94df772485c92866ca417d92137747b2e3b0a917) from https://github.com/DaveGamble/cJSON
Wow, cJSON kind of feels like the result of late night bet to get a C JSON library under 800 lines. However, it does seem like it is actually used by other projects. Maybe we could start with cJSON and make something reasonably safe and fast ourselves that implements JSON patch? |
Yeah starting with running it through |
Current coverage is 73.17% (diff: 5.40%)@@ master #833 diff @@
==========================================
Files 146 148 +2
Lines 25415 26097 +682
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 19071 19096 +25
- Misses 6344 7001 +657
Partials 0 0
|
Tweak the supplied unit test so that it emits TAP output and checks its own success/failure.
Use cJSON library instead of shortjson/json-c. Give cJSON fatal malloc/free functions so some repetitive error checking can be avoided. Use the base64 codec directly rather than through the base64_json.c convenience functions, since those assume json-c. Retain old behavior of printing strings unquoted and objects with compact formatting. Slight changes in array and object output result from different cJSON defaults.
Adjust spacing in expected array and object output. "int" and "double" are no longer distinct types. Instead, the "number" type encompasses both. The JSON spec (RFC 7159) in fact only defines the number type.
Looks like code reformatting is in the queue upstream, see DaveGamble/cJSON#24 |
Just remembered that @trws had checked in rules for clang-format that follow our style guide if |
We have RFC 7 that provides guidance on how to make our code look uniformly pretty. I would suggest we add to it whatever tools or options that best do the job. |
Thanks guys, I'll probably just wait for the reformatting to come from upstream since it's any day now, and then we'll be able to stay in sync and not subvert automatic rebase of any patches we carry. Assuming this experiment withstands the light of day that is! |
For the record, In #301 we discussed replacing json-c at length. For C, it sounded like jansson was the preferred option, but since there are some functions in json-c and jansson that have the same name, we ran into troubles transitioning. As I understand it, libflux had been migrated to jansson in #319, while other parts of flux-core like the kvs module still used json-c. The json-c users would pick up libflux's dependencies when built in-tree via the libtool scripts and get one of the duplicate symbols from the wrong lib. It was thought that pulling json-c in and building it statically as part of libflux-internal would address this, but for some reason I didn't press ahead and just do that to get us through the transition. |
@grondo You are unbelievably close to the truth with your guess as to the origins of cJSON. ;) |
@DaveGamble, well then kudos are in order! nice job on cJSON, and thanks for the software! |
Is this PR dead, Jim? |
Think I'll withdraw this for now - still on the back burner. |
The wreck exec system is worthless, remove it along with associated commands, tests, and support code. Since libjsc doesn't work without wreck, it is removed as well. Fixes flux-framework#1984 Closes flux-framework#1947 Closes flux-framework#1618 Closes flux-framework#1595 Closes flux-framework#1593 Closes flux-framework#1468 Closes flux-framework#1438 Closes flux-framework#1419 Closes flux-framework#1410 Closes flux-framework#915 Closes flux-framework#894 Closes flux-framework#866 Closes flux-framework#833 Closes flux-framework#774 Closes flux-framework#772 Closes flux-framework#335 Closes flux-framework#249
The wreck exec system is worthless, remove it along with associated commands, tests, and support code. Since libjsc doesn't work without wreck, it is removed as well. Fixes flux-framework#1984 Closes flux-framework#1947 Closes flux-framework#1618 Closes flux-framework#1595 Closes flux-framework#1593 Closes flux-framework#1534 Closes flux-framework#1468 Closes flux-framework#1443 Closes flux-framework#1438 Closes flux-framework#1419 Closes flux-framework#1410 Closes flux-framework#1407 Closes flux-framework#1393 Closes flux-framework#915 Closes flux-framework#894 Closes flux-framework#866 Closes flux-framework#833 Closes flux-framework#774 Closes flux-framework#772 Closes flux-framework#335 Closes flux-framework#249
The wreck exec system is worthless, remove it along with associated commands, tests, and support code. Since libjsc doesn't work without wreck, it is removed as well. Fixes flux-framework#1984 Closes flux-framework#1947 Closes flux-framework#1618 Closes flux-framework#1595 Closes flux-framework#1593 Closes flux-framework#1534 Closes flux-framework#1468 Closes flux-framework#1443 Closes flux-framework#1438 Closes flux-framework#1419 Closes flux-framework#1410 Closes flux-framework#1407 Closes flux-framework#1393 Closes flux-framework#915 Closes flux-framework#894 Closes flux-framework#866 Closes flux-framework#833 Closes flux-framework#774 Closes flux-framework#772 Closes flux-framework#335 Closes flux-framework#249
The wreck exec system is worthless, remove it along with associated commands, tests, and support code. Since libjsc doesn't work without wreck, it is removed as well. Fixes flux-framework#1984 Closes flux-framework#1947 Closes flux-framework#1618 Closes flux-framework#1595 Closes flux-framework#1593 Closes flux-framework#1534 Closes flux-framework#1468 Closes flux-framework#1443 Closes flux-framework#1438 Closes flux-framework#1419 Closes flux-framework#1410 Closes flux-framework#1407 Closes flux-framework#1393 Closes flux-framework#915 Closes flux-framework#894 Closes flux-framework#866 Closes flux-framework#833 Closes flux-framework#774 Closes flux-framework#772 Closes flux-framework#335 Closes flux-framework#249
closed by #1988 |
The wreck exec system is worthless, remove it along with associated commands, tests, and support code. Since libjsc doesn't work without wreck, it is removed as well. Fixes flux-framework#1984 Closes flux-framework#1947 Closes flux-framework#1618 Closes flux-framework#1595 Closes flux-framework#1593 Closes flux-framework#1468 Closes flux-framework#1438 Closes flux-framework#1419 Closes flux-framework#1410 Closes flux-framework#915 Closes flux-framework#894 Closes flux-framework#866 Closes flux-framework#833 Closes flux-framework#774 Closes flux-framework#772 Closes flux-framework#335 Closes flux-framework#249
The cJSON library is small, embeddable, reasonably fast (see JSON benchmarks), and seems widely used. It implements "JSON patch", as described in RFC 6902 which may have applications in the KVS, perhaps as a replacement for the ad-hoc "operation" array in the commit request. I'm curious whether switching to cJSON might not be a useful idea in the KVS internally, particularly if "JSON patch" can be used there. I'm also wondering if this API might be a little nicer than json-c.
In this PR, I embedded the library in flux-core and converted
flux-kvs
to use it as an experiment. So far, well...not too bad I guess. A couple of interesting bits relative to json-c:Some problems noted so far
Not for merging - just a checkpoint.