Json.h revision 6c9415e3
1/*
2 * Copyright 2014, Augustin Cavalier (waddlesplash)
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _JSON_H
6#define _JSON_H
7
8#include <Message.h>
9#include <String.h>
10
11namespace BPrivate {
12
13class BJson {
14public:
15			enum JsonObjectType {
16				JSON_TYPE_MAP = '_JTM',
17				JSON_TYPE_ARRAY = '_JTA'
18			};
19
20public:
21	static	status_t			Parse(const char* JSON, BMessage& message);
22	static	status_t			Parse(const BString& JSON, BMessage& message);
23
24private:
25	static	void				_Parse(const BString& JSON, BMessage& message);
26	static	BString				_ParseString(const BString& JSON, int32& pos);
27	static	double				_ParseNumber(const BString& JSON, int32& pos);
28	static	bool				_ParseConstant(const BString& JSON, int32& pos,
29									 const char* constant);
30};
31
32} // namespace BPrivate
33
34using BPrivate::BJson;
35
36#endif	// _JSON_H
37