回答編集履歴

1

add sample

2017/10/21 13:11

投稿

yumetodo
yumetodo

スコア5850

test CHANGED
@@ -3,3 +3,37 @@
3
3
 
4
4
 
5
5
  で上げられているようにUTF-8なstd::stringに変換してそれをjson::valueに渡す必要があります。
6
+
7
+
8
+
9
+ ```cpp
10
+
11
+ std::string ManagedStrToU8STLString(String^ s)
12
+
13
+ {
14
+
15
+ array<Byte>^ bytes = Encoding::UTF8->GetBytes(s);
16
+
17
+ std::string str;
18
+
19
+ str.resize(bytes->Length);
20
+
21
+ Marshal::Copy(bytes, 0, IntPtr(str.data()), bytes->Length);
22
+
23
+ }
24
+
25
+ ```
26
+
27
+
28
+
29
+ ```cpp
30
+
31
+ json::object pdata;
32
+
33
+ pdata[L"email"] = json::value(ManagedStrToU8STLString(TextBox1->Text));
34
+
35
+ ```
36
+
37
+
38
+
39
+ あと`pdata`の型ですが、`json::value`じゃなくて`json::object`じゃ無いでしょうか・・・?