aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-05-02 22:35:15 -0700
committerHaibo Huang <hhb@google.com>2019-05-23 16:59:21 -0700
commit9d58f79ce6ad46e7e168b4db24c20f04d0416f84 (patch)
treef93dc4db16b9ebed4afb7f293b82788086e972be /README.md
parent08305512b2141adc1b10be72e543ac9feefa0a26 (diff)
downloadjsmn-9d58f79ce6ad46e7e168b4db24c20f04d0416f84.tar.gz
Upgrade jsmn to fdcef3ebf886fa210d14956d3c068a653e76a24eandroid-o-mr1-iot-release-1.0.14android-o-mr1-iot-release-1.0.13
Test: None Change-Id: I20be18b59ca9f378213b01e98b5938a20cdc3eda
Diffstat (limited to 'README.md')
-rw-r--r--README.md34
1 files changed, 24 insertions, 10 deletions
diff --git a/README.md b/README.md
index 45436b3..0f6ed27 100644
--- a/README.md
+++ b/README.md
@@ -76,21 +76,35 @@ object hierarchy.
This approach provides enough information for parsing any JSON data and makes
it possible to use zero-copy techniques.
-Install
--------
+Usage
+-----
-To clone the repository you should have Git installed. Just run:
+Download `jsmn.h`, include it, done.
- $ git clone https://github.com/zserge/jsmn
+```
+#include "jsmn.h"
-Repository layout is simple: jsmn.c and jsmn.h are library files, tests are in
-the jsmn\_test.c, you will also find README, LICENSE and Makefile files inside.
+...
+jsmn_parser p;
+jsmntok_t t[128]; /* We expect no more than 128 JSON tokens */
-To build the library, run `make`. It is also recommended to run `make test`.
-Let me know, if some tests fail.
+jsmn_init(&p);
+r = jsmn_parse(&p, s, strlen(s), t, 128);
+```
-If build was successful, you should get a `libjsmn.a` library.
-The header file you should include is called `"jsmn.h"`.
+Since jsmn is a single-header, header-only library, for more complex use cases
+you might need to define additional macros. `#define JSMN_STATIC` hides all
+jsmn API symbols by making them static. Also, if you want to include `jsmn.h`
+from multiple C files, to avoid duplication of symbols you may define `JSMN_HEADER` macro.
+
+```
+/* In every .c file that uses jsmn include only declarations: */
+#define JSMN_HEADER
+#include "jsmn.h"
+
+/* Additionally, create one jsmn.c file for jsmn implementation: */
+#include "jsmn.h"
+```
API
---