struct jsonParserContextStruct {
int state; /* what are we currently parsing */
- char* chunk; /* the chunk we're currently parsing */
+ const char* chunk; /* the chunk we're currently parsing */
int index; /* where we are in parsing the current chunk */
int chunksize; /* the size of the current chunk */
int flags; /* parser flags */
* @param datalen The size of the chunk to parser
* @param flags Reserved
*/
-int jsonParseChunk( jsonParserContext* ctx, char* data, int datalen, int flags );
+int jsonParseChunk( jsonParserContext* ctx, const char* data, int datalen, int flags );
/**
* @param str The string to parser
* @return The resulting JSON object or NULL on error
*/
-jsonObject* jsonParseString( char* str );
-jsonObject* jsonParseStringRaw( char* str );
+jsonObject* jsonParseString( const char* str );
+jsonObject* jsonParseStringRaw( const char* str );
-jsonObject* jsonParseStringFmt( char* str, ... );
+jsonObject* jsonParseStringFmt( const char* str, ... );
/**
* Parses a JSON string;
jsonObject* json_parse_string(char* string);
-jsonObject* legacy_jsonParseString(char* string);
-jsonObject* legacy_jsonParseStringFmt( char* string, ... );
+jsonObject* legacy_jsonParseString(const char* string);
+jsonObject* legacy_jsonParseStringFmt( const char* string, ... );
jsonObject* json_parse_file( const char* filename );
/* provide 2 different JSON parsers and serializers to support legacy JSON */
- jsonObject* (*parseJSONFunc) (char*) = legacy_jsonParseString;
+ jsonObject* (*parseJSONFunc) (const char*) = legacy_jsonParseString;
char* (*jsonToStringFunc) (const jsonObject*) = legacy_jsonObjectToJSON;
if(dir_conf->legacyJSON) {
-int jsonParseChunk( jsonParserContext* ctx, char* data, int datalen, int flags ) {
+int jsonParseChunk( jsonParserContext* ctx, const char* data, int datalen, int flags ) {
if( !( ctx && ctx->handler && data && datalen > 0 )) return -1;
ctx->chunksize = datalen;
free(p);
}
-static jsonObject* _jsonParseStringImpl(char* str, void (*errorHandler) (const char*) ) {
+static jsonObject* _jsonParseStringImpl(const char* str, void (*errorHandler) (const char*) ) {
jsonInternalParser* parser = _jsonNewInternalParser();
parser->handleError = errorHandler;
jsonParseChunk( parser->ctx, str, strlen(str), JSON_PARSE_LAST_CHUNK );
return _jsonParseStringImpl(VA_BUF, errorHandler);
}
-jsonObject* jsonParseString( char* str ) {
+jsonObject* jsonParseString( const char* str ) {
if(!str) return NULL;
jsonObject* obj = _jsonParseStringImpl(str, NULL);
jsonObject* obj2 = jsonObjectDecodeClass(obj);
return obj2;
}
-jsonObject* jsonParseStringRaw( char* str ) {
+jsonObject* jsonParseStringRaw( const char* str ) {
if(!str) return NULL;
return _jsonParseStringImpl(str, NULL);
}
-jsonObject* jsonParseStringFmt( char* str, ... ) {
+jsonObject* jsonParseStringFmt( const char* str, ... ) {
if(!str) return NULL;
VA_LIST_TO_STRING(str);
return _jsonParseStringImpl(VA_BUF, NULL);
int current_strlen;
-jsonObject* legacy_jsonParseString( char* string) {
- return json_parse_string( string );
+jsonObject* legacy_jsonParseString( const char* string) {
+ return json_parse_string( (char*) string );
}
-jsonObject* legacy_jsonParseStringFmt( char* string, ... ) {
+jsonObject* legacy_jsonParseStringFmt( const char* string, ... ) {
VA_LIST_TO_STRING(string);
return json_parse_string( VA_BUF );
}