json-gen-c  0.1.5
json-gen-c generate C code for json manipulation
lsp_jsonrpc.h
1/*
2 * lsp_jsonrpc.h - JSON-RPC 2.0 message framing for LSP
3 *
4 * Handles Content-Length header-based framing on stdin/stdout
5 * and lightweight JSON object access for LSP messages.
6 */
7
8#ifndef LSP_JSONRPC_H
9#define LSP_JSONRPC_H
10
11#include "utils/sstr.h"
12#include <stdio.h>
13
14/* Simple JSON value representation for LSP messages. */
15enum lsp_json_type {
16 LSP_JSON_NULL,
17 LSP_JSON_BOOL,
18 LSP_JSON_NUMBER,
19 LSP_JSON_STRING,
20 LSP_JSON_ARRAY,
21 LSP_JSON_OBJECT
22};
23
25 enum lsp_json_type type;
26 union {
27 int bool_val;
28 long number_val;
29 sstr_t string_val;
30 struct {
31 struct lsp_json_value *items;
32 int count;
33 } array;
34 struct {
35 char **keys;
36 struct lsp_json_value *values;
37 int count;
38 } object;
39 } u;
40};
41
47sstr_t lsp_jsonrpc_read(FILE *in);
48
53void lsp_jsonrpc_write(FILE *out, sstr_t json_body);
54
59int lsp_json_parse(const char *json, int len, struct lsp_json_value *out);
60
64void lsp_json_free(struct lsp_json_value *val);
65
70struct lsp_json_value *lsp_json_get(struct lsp_json_value *val, const char *key);
71
76const char *lsp_json_string(struct lsp_json_value *val);
77
82long lsp_json_number(struct lsp_json_value *val);
83
90sstr_t lsp_jsonrpc_response(long id, const char *result_json);
91
98sstr_t lsp_jsonrpc_notification(const char *method, const char *params_json);
99
105void lsp_json_escape_string(const char *s, sstr_t out);
106
107#endif /* LSP_JSONRPC_H */
sstr_t are objects that represent sequences of characters.
void * sstr_t
sstr_t are objects that represent sequences of characters.
Definition sstr.h:75
Definition lsp_jsonrpc.h:24