1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/**
* @file llsdjson.cpp
* @brief LLSD flexible data system
*
* $LicenseInfo:firstyear=2015&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2015, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLSDJSON_H
#define LL_LLSDJSON_H
#include <map>
#include <string>
#include <vector>
#include "stdtypes.h"
#include "llsd.h"
#include <boost/json.hpp>
/// Convert a parsed JSON structure into LLSD maintaining member names and
/// array indexes.
/// JSON/JavaScript types are converted as follows:
///
/// JSON Type | LLSD Type
/// --------------+--------------
/// null | undefined
/// integer | LLSD::Integer
/// unsigned | LLSD::Integer
/// real/numeric | LLSD::Real
/// string | LLSD::String
/// boolean | LLSD::Boolean
/// array | LLSD::Array
/// object | LLSD::Map
///
/// For maps and arrays child entries will be converted and added to the structure.
/// Order is preserved for an array but not for objects.
LLSD LlsdFromJson(const boost::json::value &val);
/// Convert an LLSD object into Parsed JSON object maintaining member names and
/// array indexs.
///
/// Types are converted as follows:
/// LLSD Type | JSON Type
/// --------------+----------------
/// TypeUndefined | null
/// TypeBoolean | boolean
/// TypeInteger | integer
/// TypeReal | real/numeric
/// TypeString | string
/// TypeURI | string
/// TypeDate | string
/// TypeUUID | string
/// TypeMap | object
/// TypeArray | array
/// TypeBinary | unsupported
boost::json::value LlsdToJson(const LLSD &val);
#endif // LL_LLSDJSON_H
|