Skip to content

Commit 4ecfb2e

Browse files
committed
TFS Sync
1 parent bee6dd2 commit 4ecfb2e

File tree

4 files changed

+16
-28
lines changed

4 files changed

+16
-28
lines changed

Release/include/cpprest/json.h

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,6 @@ namespace web { namespace json
7575
/// </summary>
7676
enum value_type { Number, Boolean, String, Object, Array, Null };
7777

78-
/// <summary>
79-
/// Typedef for the standard container holding fields. This is used when constructing an
80-
/// object from existing objects.
81-
/// </summary>
82-
typedef std::vector<std::pair<utility::string_t,json::value>> field_map;
83-
84-
/// <summary>
85-
/// Typedef for the standard container holding array elements. This is used when constructing an
86-
/// array from existing objects.
87-
/// </summary>
88-
typedef std::vector<json::value> array_vector;
89-
9078
/// <summary>
9179
/// Constructor creating a null value
9280
/// </summary>
@@ -215,11 +203,11 @@ namespace web { namespace json
215203
static _ASYNCRTIMP json::value __cdecl object();
216204

217205
/// <summary>
218-
/// Creates an object value from a map of field/values
206+
/// Creates an object value from a collection of field/values
219207
/// </summary>
220-
/// <param name="fields">A map of field names associated with JSON values</param>
208+
/// <param name="fields">Field names associated with JSON values</param>
221209
/// <returns>A non-empty JSON object value</returns>
222-
static _ASYNCRTIMP json::value __cdecl object(json::value::field_map fields);
210+
static _ASYNCRTIMP json::value __cdecl object(std::vector<std::pair<::utility::string_t, value>> fields);
223211

224212
/// <summary>
225213
/// Creates an empty JSON array
@@ -237,9 +225,9 @@ namespace web { namespace json
237225
/// <summary>
238226
/// Creates a JSON array
239227
/// </summary>
240-
/// <param name="elements">A vector of JSON values, </param>
228+
/// <param name="elements">A vector of JSON values</param>
241229
/// <returns>A JSON array value</returns>
242-
static _ASYNCRTIMP json::value __cdecl array(array_vector elements);
230+
static _ASYNCRTIMP json::value __cdecl array(std::vector<value> elements);
243231

244232
/// <summary>
245233
/// Accesses the type of JSON value the current value instance is
@@ -724,7 +712,7 @@ namespace web { namespace json
724712

725713
private:
726714
object() : m_elements(), m_sorted(false) { }
727-
object(json::value::field_map elements) : m_elements(std::move(elements)), m_sorted(false) { }
715+
object(storage_type elements) : m_elements(std::move(elements)), m_sorted(false) { }
728716
object(const object& obj); // non copyable
729717
object& operator=(const object& obj) // non copyable
730718
{
@@ -1360,7 +1348,7 @@ namespace web { namespace json
13601348
{
13611349
}
13621350

1363-
_Object(json::value::field_map fields) : m_object(std::move(fields)) { }
1351+
_Object(object::storage_type fields) : m_object(std::move(fields)) { }
13641352

13651353
_ASYNCRTIMP _Object(const _Object& other);
13661354

Release/src/json/json.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ web::json::value web::json::value::object()
200200
);
201201
}
202202

203-
web::json::value web::json::value::object(web::json::value::field_map fields)
203+
web::json::value web::json::value::object(std::vector<std::pair<::utility::string_t, value>> fields)
204204
{
205205
std::unique_ptr<details::_Value> ptr = utility::details::make_unique<details::_Object>(std::move(fields));
206206
return web::json::value(std::move(ptr)
@@ -230,7 +230,7 @@ web::json::value web::json::value::array(size_t size)
230230
);
231231
}
232232

233-
web::json::value web::json::value::array(json::value::array_vector elements)
233+
web::json::value web::json::value::array(std::vector<value> elements)
234234
{
235235
std::unique_ptr<details::_Value> ptr = utility::details::make_unique<details::_Array>(std::move(elements));
236236
return web::json::value(std::move(ptr)

Release/tests/Functional/json/construction_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ TEST(factory_overloads)
205205

206206
TEST(object_construction)
207207
{
208-
// Factory which takes a map.
209-
json::value::field_map f;
208+
// Factory which takes a vector.
209+
std::vector<std::pair<string_t, json::value>> f;
210210
f.push_back(std::make_pair(U("abc"), json::value(true)));
211211
f.push_back(std::make_pair(U("xyz"), json::value(44)));
212212
json::value obj = json::value::object(f);
@@ -246,7 +246,7 @@ TEST(object_construction)
246246
TEST(array_construction)
247247
{
248248
// Constructor which takes a vector.
249-
json::value::array_vector e;
249+
std::vector<json::value> e;
250250
e.push_back(json::value(false));
251251
e.push_back(json::value::string(U("hehe")));
252252
json::value arr = json::value::array(e);

Release/tests/Functional/json/iterator_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ TEST(std_algorithms)
278278
json::value v_array = json::value::parse(U("[44, true, false]"));
279279
auto _where =
280280
std::find_if(std::begin(v_array.as_array()), std::end(v_array.as_array()),
281-
[&](json::value::array_vector::iterator::value_type value)
281+
[&](json::array::iterator::value_type value)
282282
{
283283
return value.is_boolean();
284284
});
@@ -290,10 +290,10 @@ TEST(std_algorithms)
290290
{
291291
// copy_if
292292
json::value v_array = json::value::parse(U("[44, true, false]"));
293-
std::vector<json::value::array_vector::iterator::value_type> v_target(v_array.size());
293+
std::vector<json::array::iterator::value_type> v_target(v_array.size());
294294
auto _where =
295295
std::copy_if(std::begin(v_array.as_array()), std::end(v_array.as_array()), std::begin(v_target),
296-
[&](json::value::array_vector::iterator::value_type value)
296+
[&](json::array::iterator::value_type value)
297297
{
298298
return value.is_boolean();
299299
});
@@ -306,7 +306,7 @@ TEST(std_algorithms)
306306
std::vector<json::value> v_target(v_array.size());
307307
auto _where =
308308
std::transform(std::begin(v_array.as_array()), std::end(v_array.as_array()), std::begin(v_target),
309-
[&](json::value::array_vector::iterator::value_type) -> json::value
309+
[&](json::array::iterator::value_type) -> json::value
310310
{
311311
return json::value::number(17);
312312
});

0 commit comments

Comments
 (0)