OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 protected: | 220 protected: |
221 void prettyWriteJSONInternal(StringBuilder* output, int depth) const override; | 221 void prettyWriteJSONInternal(StringBuilder* output, int depth) const override; |
222 | 222 |
223 private: | 223 private: |
224 JSONObject(); | 224 JSONObject(); |
225 template <typename T> | 225 template <typename T> |
226 void set(const String& key, std::unique_ptr<T>& value) { | 226 void set(const String& key, std::unique_ptr<T>& value) { |
227 DCHECK(value); | 227 DCHECK(value); |
228 if (m_data.set(key, std::move(value)).isNewEntry) | 228 if (m_data.set(key, std::move(value)).isNewEntry) |
229 m_order.append(key); | 229 m_order.push_back(key); |
230 } | 230 } |
231 | 231 |
232 using Dictionary = HashMap<String, std::unique_ptr<JSONValue>>; | 232 using Dictionary = HashMap<String, std::unique_ptr<JSONValue>>; |
233 Dictionary m_data; | 233 Dictionary m_data; |
234 Vector<String> m_order; | 234 Vector<String> m_order; |
235 }; | 235 }; |
236 | 236 |
237 class PLATFORM_EXPORT JSONArray : public JSONValue { | 237 class PLATFORM_EXPORT JSONArray : public JSONValue { |
238 public: | 238 public: |
239 static std::unique_ptr<JSONArray> create() { | 239 static std::unique_ptr<JSONArray> create() { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 JSONArray(); | 279 JSONArray(); |
280 Vector<std::unique_ptr<JSONValue>> m_data; | 280 Vector<std::unique_ptr<JSONValue>> m_data; |
281 }; | 281 }; |
282 | 282 |
283 PLATFORM_EXPORT void escapeStringForJSON(const String&, StringBuilder*); | 283 PLATFORM_EXPORT void escapeStringForJSON(const String&, StringBuilder*); |
284 void doubleQuoteStringForJSON(const String&, StringBuilder*); | 284 void doubleQuoteStringForJSON(const String&, StringBuilder*); |
285 | 285 |
286 } // namespace blink | 286 } // namespace blink |
287 | 287 |
288 #endif // JSONValues_h | 288 #endif // JSONValues_h |
OLD | NEW |