您好我正在使用ruby-2.5.0
和Rails 5
处理JSON
项目。我的json
无效,但我想将此Like:-
{
"data": "my json"
}
作为字符串(任意键的值)发送。
JSON
**** ** JSON for Image / Page 1 ** ** ** {
"Lines": [{
"Words": [{
"WordText": "Coles",
"Left": 53,
"Top": 59,
"Height": 20,
"Width": 63
},
{
"WordText": "Supermarkets",
"Left": 130,
"Top": 58,
"Height": 24,
"Width": 153
},
{
"WordText": "Austral",
"Left": 296,
"Top": 58,
"Height": 21,
"Width": 85
},
{
"WordText": "ia",
"Left": 389,
"Top": 57,
"Height": 22,
"Width": 22
},
{
"WordText": "Pty",
"Left": 424,
"Top": 58,
"Height": 24,
"Width": 38
},
{
"WordText": "Ltd",
"Left": 476,
"Top": 58,
"Height": 21,
"Width": 38
}
],
"MaxHeight": 24,
"MinTop": 57
},
{
"Words": [{
"WordText": "lax",
"Left": 78,
"Top": 86,
"Height": 21,
"Width": 38
},
{
"WordText": "Invoice",
"Left": 130,
"Top": 86,
"Height": 21,
"Width": 89
},
{
"WordText": "ABN:",
"Left": 232,
"Top": 85,
"Height": 22,
"Width": 47
},
{
"WordText": "45",
"Left": 296,
"Top": 86,
"Height": 20,
"Width": 25
},
{
"WordText": "004",
"Left": 335,
"Top": 85,
"Height": 21,
"Width": 38
},
{
"WordText": "189",
"Left": 388,
"Top": 85,
"Height": 21,
"Width": 36
},
{
"WordText": "708",
"Left": 437,
"Top": 85,
"Height": 21,
"Width": 38
}
],
"MaxHeight": 22,
"MinTop": 85
},
{
"Words": [{
"WordText": "COLLECT",
"Left": 304,
"Top": 142,
"Height": 36,
"Width": 184
}],
"MaxHeight": 36,
"MinTop": 142
},
{
"Words": [{
"WordText": "SPORTS",
"Left": 161,
"Top": 162,
"Height": 23,
"Width": 72
},
{
"WordText": "tor",
"Left": 238,
"Top": 166,
"Height": 12,
"Width": 20
}
],
"MaxHeight": 23,
"MinTop": 162
},
{
"Words": [{
"WordText": "VOUCHERS",
"Left": 303,
"Top": 188,
"Height": 28,
"Width": 182
}],
"MaxHeight": 28,
"MinTop": 188
},
{
"Words": [{
"WordText": "FOR",
"Left": 306,
"Top": 226,
"Height": 18,
"Width": 38
},
{
"WordText": "SPORTS",
"Left": 349,
"Top": 226,
"Height": 18,
"Width": 78
},
{
"WordText": "GEAR",
"Left": 431,
"Top": 226,
"Height": 17,
"Width": 55
}
],
"MaxHeight": 18,
"MinTop": 226
},
{
"Words": [{
"WordText": "Store:",
"Left": 28,
"Top": 285,
"Height": 20,
"Width": 72
},
{
"WordText": "340",
"Left": 118,
"Top": 285,
"Height": 20,
"Width": 37
}
],
"MaxHeight": 20,
"MinTop": 285
},
{
"Words": [{
"WordText": "-",
"Left": 170,
"Top": 294,
"Height": 2,
"Width": 9
},
{
"WordText": "CS",
"Left": 195,
"Top": 285,
"Height": 19,
"Width": 24
},
{
"WordText": "VICTORIA",
"Left": 233,
"Top": 285,
"Height": 20,
"Width": 101
},
{
"WordText": "PARK",
"Left": 348,
"Top": 285,
"Height": 19,
"Width": 50
},
{
"WordText": "EAS",
"Left": 413,
"Top": 285,
"Height": 19,
"Width": 36
}
],
"MaxHeight": 20,
"MinTop": 285
},
{
"Words": [{
"WordText": "Store",
"Left": 28,
"Top": 312,
"Height": 21,
"Width": 63
},
{
"WordText": "Manager:",
"Left": 105,
"Top": 312,
"Height": 23,
"Width": 98
},
{
"WordText": "John",
"Left": 221,
"Top": 311,
"Height": 21,
"Width": 50
},
{
"WordText": "Chant",
"Left": 285,
"Top": 312,
"Height": 20,
"Width": 61
},
{
"WordText": "I",
"Left": 351,
"Top": 312,
"Height": 20,
"Width": 4
},
{
"WordText": "er",
"Left": 362,
"Top": 316,
"Height": 16,
"Width": 23
}
],
"MaxHeight": 23,
"MinTop": 311
},
{
"Words": [{
"WordText": "Phone",
"Left": 28,
"Top": 339,
"Height": 21,
"Width": 63
}],
"MaxHeight": 21,
"MinTop": 339
},
{
"Words": [{
"WordText": "08",
"Left": 170,
"Top": 339,
"Height": 19,
"Width": 23
},
{
"WordText": "94723299",
"Left": 208,
"Top": 339,
"Height": 20,
"Width": 101
}
],
"MaxHeight": 20,
"MinTop": 339
},
{
"Words": [{
"WordText": "Served",
"Left": 29,
"Top": 366,
"Height": 20,
"Width": 75
},
{
"WordText": "By:",
"Left": 118,
"Top": 366,
"Height": 22,
"Width": 33
},
{
"WordText": "Assisted",
"Left": 170,
"Top": 366,
"Height": 21,
"Width": 101
},
{
"WordText": "Checkout",
"Left": 285,
"Top": 366,
"Height": 20,
"Width": 100
}
],
"MaxHeight": 22,
"MinTop": 366
},
{
"Words": [{
"WordText": "12:05",
"Left": 479,
"Top": 417,
"Height": 21,
"Width": 62
}],
"MaxHeight": 21,
"MinTop": 417
},
{
"Words": [{
"WordText": "36",
"Left": 478,
"Top": 524,
"Height": 19,
"Width": 24
},
{
"WordText": "oo",
"Left": 517,
"Top": 525,
"Height": 18,
"Width": 24
}
],
"MaxHeight": 19,
"MinTop": 524
},
{
"Words": [{
"WordText": "10.40",
"Left": 480,
"Top": 577,
"Height": 20,
"Width": 61
}],
"MaxHeight": 20,
"MinTop": 577
},
{
"Words": [{
"WordText": "31.00",
"Left": 478,
"Top": 603,
"Height": 20,
"Width": 63
}],
"MaxHeight": 20,
"MinTop": 603
},
{
"Words": [{
"WordText": "121",
"Left": 171,
"Top": 392,
"Height": 19,
"Width": 35
}],
"MaxHeight": 19,
"MinTop": 392
},
{
"Words": [{
"WordText": "24/02/2018",
"Left": 170,
"Top": 417,
"Height": 22,
"Width": 127
}],
"MaxHeight": 22,
"MinTop": 417
},
{
"Words": [{
"WordText": "Date:",
"Left": 29,
"Top": 418,
"Height": 21,
"Width": 59
}],
"MaxHeight": 21,
"MinTop": 418
},
{
"Words": [{
"WordText": "Descri",
"Left": 29,
"Top": 471,
"Height": 23,
"Width": 72
},
{
"WordText": "pt",
"Left": 106,
"Top": 473,
"Height": 21,
"Width": 25
},
{
"WordText": "i",
"Left": 134,
"Top": 471,
"Height": 20,
"Width": 5
},
{
"WordText": "on",
"Left": 145,
"Top": 476,
"Height": 15,
"Width": 25
}
],
"MaxHeight": 23,
"MinTop": 471
},
{
"Words": [{
"WordText": "Receipt:",
"Left": 375,
"Top": 391,
"Height": 23,
"Width": 97
},
{
"WordText": "9500",
"Left": 490,
"Top": 392,
"Height": 18,
"Width": 50
}
],
"MaxHeight": 23,
"MinTop": 391
},
{
"Words": [{
"WordText": "Time:",
"Left": 375,
"Top": 417,
"Height": 21,
"Width": 59
}],
"MaxHeight": 21,
"MinTop": 417
},
{
"Words": [{
"WordText": "x%HUGGIES",
"Left": 31,
"Top": 525,
"Height": 20,
"Width": 113
},
{
"WordText": "ULTRTRM",
"Left": 158,
"Top": 525,
"Height": 20,
"Width": 88
},
{
"WordText": "NWBR",
"Left": 260,
"Top": 524,
"Height": 20,
"Width": 50
},
{
"WordText": "5APACK",
"Left": 324,
"Top": 524,
"Height": 20,
"Width": 76
}
],
"MaxHeight": 20,
"MinTop": 524
},
{
"Words": [{
"WordText": "3",
"Left": 94,
"Top": 552,
"Height": 19,
"Width": 11
},
{
"WordText": "@",
"Left": 119,
"Top": 552,
"Height": 19,
"Width": 12
},
{
"WordText": "$12.00",
"Left": 144,
"Top": 551,
"Height": 23,
"Width": 77
},
{
"WordText": "EACH",
"Left": 235,
"Top": 550,
"Height": 21,
"Width": 50
}
],
"MaxHeight": 23,
"MinTop": 550
},
{
"Words": [{
"WordText": "%",
"Left": 30,
"Top": 578,
"Height": 19,
"Width": 11
},
{
"WordText": "SCHOLL",
"Left": 56,
"Top": 578,
"Height": 20,
"Width": 75
},
{
"WordText": "FOAM",
"Left": 146,
"Top": 578,
"Height": 21,
"Width": 49
},
{
"WordText": "PADDING",
"Left": 210,
"Top": 577,
"Height": 22,
"Width": 88
},
{
"WordText": "IPACK",
"Left": 313,
"Top": 577,
"Height": 20,
"Width": 61
}
],
"MaxHeight": 22,
"MinTop": 577
},
{
"Words": [{
"WordText": "%",
"Left": 30,
"Top": 605,
"Height": 19,
"Width": 11
},
{
"WordText": "GILLETTE",
"Left": 56,
"Top": 604,
"Height": 21,
"Width": 101
},
{
"WordText": "MACH",
"Left": 171,
"Top": 604,
"Height": 21,
"Width": 50
},
{
"WordText": "3",
"Left": 235,
"Top": 604,
"Height": 19,
"Width": 12
},
{
"WordText": "CART",
"Left": 261,
"Top": 604,
"Height": 20,
"Width": 48
},
{
"WordText": "12PACK",
"Left": 326,
"Top": 603,
"Height": 21,
"Width": 74
}
],
"MaxHeight": 21,
"MinTop": 603
},
{
"Words": [{
"WordText": "%",
"Left": 30,
"Top": 632,
"Height": 19,
"Width": 12
},
{
"WordText": "CETAPHIL",
"Left": 56,
"Top": 630,
"Height": 22,
"Width": 101
},
{
"WordText": "WASH",
"Left": 171,
"Top": 630,
"Height": 22,
"Width": 50
},
{
"WordText": "SHAM",
"Left": 261,
"Top": 630,
"Height": 21,
"Width": 50
},
{
"WordText": "230ML",
"Left": 325,
"Top": 629,
"Height": 22,
"Width": 63
}
],
"MaxHeight": 22,
"MinTop": 629
},
{
"Words": [{
"WordText": "x%GARNIER",
"Left": 32,
"Top": 658,
"Height": 20,
"Width": 112
},
{
"WordText": "FRUCTIS",
"Left": 159,
"Top": 658,
"Height": 20,
"Width": 88
},
{
"WordText": "SHAM",
"Left": 262,
"Top": 658,
"Height": 20,
"Width": 49
},
{
"WordText": "700ML",
"Left": 325,
"Top": 657,
"Height": 21,
"Width": 62
}
],
"MaxHeight": 21,
"MinTop": 657
},
{
"Words": [{
"WordText": "*XGARNIER",
"Left": 31,
"Top": 684,
"Height": 20,
"Width": 114
},
{
"WordText": "FRUCTIS",
"Left": 159,
"Top": 684,
"Height": 20,
"Width": 88
},
{
"WordText": "SHAM",
"Left": 262,
"Top": 684,
"Height": 20,
"Width": 49
}
],
"MaxHeight": 20,
"MinTop": 684
},
{
"Words": [{
"WordText": "%",
"Left": 31,
"Top": 710,
"Height": 20,
"Width": 11
},
{
"WordText": "SUDOCREAM",
"Left": 57,
"Top": 710,
"Height": 21,
"Width": 114
},
{
"WordText": "GOGRAM",
"Left": 185,
"Top": 709,
"Height": 21,
"Width": 75
}
],
"MaxHeight": 21,
"MinTop": 709
},
{
"Words": [{
"WordText": "%",
"Left": 31,
"Top": 738,
"Height": 19,
"Width": 12
},
{
"WordText": "FERRERO",
"Left": 57,
"Top": 737,
"Height": 20,
"Width": 88
},
{
"WordText": "EGGS",
"Left": 159,
"Top": 737,
"Height": 21,
"Width": 50
},
{
"WordText": "IOOGRAM",
"Left": 225,
"Top": 736,
"Height": 21,
"Width": 86
}
],
"MaxHeight": 21,
"MinTop": 736
},
{
"Words": [{
"WordText": "%",
"Left": 32,
"Top": 764,
"Height": 20,
"Width": 11
},
{
"WordText": "FERRERO",
"Left": 57,
"Top": 763,
"Height": 22,
"Width": 88
},
{
"WordText": "EGGS",
"Left": 160,
"Top": 763,
"Height": 22,
"Width": 49
},
{
"WordText": "IOOGRAM",
"Left": 225,
"Top": 762,
"Height": 22,
"Width": 87
}
],
"MaxHeight": 22,
"MinTop": 762
},
{
"Words": [{
"WordText": "MARS",
"Left": 32,
"Top": 791,
"Height": 20,
"Width": 50
},
{
"WordText": "KINDER",
"Left": 96,
"Top": 790,
"Height": 22,
"Width": 76
},
{
"WordText": "LINDT",
"Left": 185,
"Top": 790,
"Height": 22,
"Width": 63
},
{
"WordText": "2",
"Left": 262,
"Top": 790,
"Height": 21,
"Width": 13
},
{
"WordText": "FOR$7",
"Left": 288,
"Top": 788,
"Height": 24,
"Width": 63
}
],
"MaxHeight": 24,
"MinTop": 788
},
{
"Words": [{
"WordText": "CREAMY",
"Left": 122,
"Top": 818,
"Height": 20,
"Width": 73
},
{
"WordText": "YOGHURT",
"Left": 211,
"Top": 817,
"Height": 21,
"Width": 87
},
{
"WordText": "850ML",
"Left": 314,
"Top": 817,
"Height": 20,
"Width": 62
}
],
"MaxHeight": 21,
"MinTop": 817
},
{
"Words": [{
"WordText": "x%SANPEl-LEGRINO",
"Left": 32,
"Top": 844,
"Height": 21,
"Width": 191
},
{
"WordText": "MWATER",
"Left": 237,
"Top": 843,
"Height": 21,
"Width": 75
},
{
"WordText": "ILITRE",
"Left": 328,
"Top": 843,
"Height": 21,
"Width": 74
}
],
"MaxHeight": 21,
"MinTop": 843
},
{
"Words": [{
"WordText": "*",
"Left": 32,
"Top": 876,
"Height": 10,
"Width": 10
},
{
"WordText": "GOLD",
"Left": 58,
"Top": 870,
"Height": 21,
"Width": 49
},
{
"WordText": "CHOICE",
"Left": 122,
"Top": 870,
"Height": 21,
"Width": 75
},
{
"WordText": "CANOLA",
"Left": 212,
"Top": 870,
"Height": 21,
"Width": 75
},
{
"WordText": "0",
"Left": 301,
"Top": 869,
"Height": 19,
"Width": 12
},
{
"WordText": "4LITRE",
"Left": 327,
"Top": 869,
"Height": 21,
"Width": 75
}
],
"MaxHeight": 21,
"MinTop": 869
},
{
"Words": [{
"WordText": "Total",
"Left": 32,
"Top": 923,
"Height": 21,
"Width": 59
},
{
"WordText": "for",
"Left": 110,
"Top": 923,
"Height": 21,
"Width": 37
},
{
"WordText": "14",
"Left": 162,
"Top": 923,
"Height": 22,
"Width": 23
},
{
"WordText": "items:",
"Left": 201,
"Top": 923,
"Height": 21,
"Width": 70
}
],
"MaxHeight": 22,
"MinTop": 923
},
{
"Words": [{
"WordText": "EFT",
"Left": 33,
"Top": 976,
"Height": 20,
"Width": 36
}],
"MaxHeight": 20,
"MinTop": 976
},
{
"Words": [{
"WordText": "RRN",
"Left": 34,
"Top": 1216,
"Height": 20,
"Width": 37
},
{
"WordText": "001210950000",
"Left": 86,
"Top": 1215,
"Height": 21,
"Width": 152
}
],
"MaxHeight": 21,
"MinTop": 1215
},
{
"Words": [{
"WordText": "AUTH",
"Left": 35,
"Top": 1242,
"Height": 20,
"Width": 50
},
{
"WordText": "304336",
"Left": 99,
"Top": 1242,
"Height": 20,
"Width": 75
}
],
"MaxHeight": 20,
"MinTop": 1242
},
{
"Words": [{
"WordText": "WA",
"Left": 443,
"Top": 1055,
"Height": 20,
"Width": 24
},
{
"WordText": "AU",
"Left": 495,
"Top": 1055,
"Height": 20,
"Width": 24
}
],
"MaxHeight": 20,
"MinTop": 1055
},
{
"Words": [{
"WordText": "65696971",
"Left": 302,
"Top": 1082,
"Height": 20,
"Width": 101
}],
"MaxHeight": 20,
"MinTop": 1082
},
{
"Words": [{
"WordText": "BKB40C1",
"Left": 444,
"Top": 1082,
"Height": 20,
"Width": 74
}],
"MaxHeight": 20,
"MinTop": 1082
},
{
"Words": [{
"WordText": "MASTERCARD",
"Left": 392,
"Top": 1108,
"Height": 20,
"Width": 127
}],
"MaxHeight": 20,
"MinTop": 1108
},
{
"Words": [{
"WordText": "Bankwest",
"Left": 328,
"Top": 1135,
"Height": 21,
"Width": 101
},
{
"WordText": "Credit",
"Left": 444,
"Top": 1135,
"Height": 21,
"Width": 74
}
],
"MaxHeight": 21,
"MinTop": 1135
},
{
"Words": [{
"WordText": "A0000000041010",
"Left": 342,
"Top": 1161,
"Height": 21,
"Width": 177
}],
"MaxHeight": 21,
"MinTop": 1161
},
{
"Words": [{
"WordText": "AUD$",
"Left": 380,
"Top": 1187,
"Height": 23,
"Width": 50
},
{
"WordText": "122992",
"Left": 445,
"Top": 1188,
"Height": 20,
"Width": 75
}
],
"MaxHeight": 23,
"MinTop": 1187
},
{
"Words": [{
"WordText": "(00)",
"Left": 371,
"Top": 1215,
"Height": 20,
"Width": 43
},
{
"WordText": "APPROVED",
"Left": 419,
"Top": 1214,
"Height": 21,
"Width": 101
}
],
"MaxHeight": 21,
"MinTop": 1214
},
{
"Words": [{
"WordText": "*",
"Left": 215,
"Top": 1353,
"Height": 11,
"Width": 11
},
{
"WordText": "z;",
"Left": 242,
"Top": 1354,
"Height": 8,
"Width": 10
},
{
"WordText": "Specials",
"Left": 266,
"Top": 1347,
"Height": 25,
"Width": 102
}
],
"MaxHeight": 25,
"MinTop": 1347
},
{
"Words": [{
"WordText": "X",
"Left": 176,
"Top": 1375,
"Height": 19,
"Width": 13
},
{
"WordText": "=",
"Left": 203,
"Top": 1381,
"Height": 8,
"Width": 11
},
{
"WordText": "Taxable",
"Left": 228,
"Top": 1374,
"Height": 20,
"Width": 89
},
{
"WordText": "items",
"Left": 332,
"Top": 1374,
"Height": 20,
"Width": 62
}
],
"MaxHeight": 20,
"MinTop": 1374
},
{
"Words": [{
"WordText": "Total",
"Left": 37,
"Top": 1430,
"Height": 38,
"Width": 91
},
{
"WordText": "Savings",
"Left": 155,
"Top": 1430,
"Height": 44,
"Width": 136
}
],
"MaxHeight": 44,
"MinTop": 1430
},
{
"Words": [{
"WordText": "$39.18",
"Left": 451,
"Top": 1426,
"Height": 45,
"Width": 117
}],
"MaxHeight": 45,
"MinTop": 1426
}
],
"HasOverlay": true,
"Message": "Total lines: 71"
},
"FileParseExitCode": 1,
"ParsedText": Coles Supermarkets Austral ia Pty Ltd
lax Invoice ABN: 45 004 189 708
COLLECT
SPORTS tor
VOUCHERS
FOR SPORTS GEAR
Store: 340 -
CS VICTORIA PARK EAS
Store Manager: John Chant I er
Phone
08 94723299
Served By: Assisted Checkout
12: 05
36 oo
10.40
31.00
121
24 / 02 / 2018
Date:
Descri pt i on
Receipt: 9500
Time:
x % HUGGIES ULTRTRM NWBR 5 APACK
3 @ $12 .00 EACH
%
SCHOLL FOAM PADDING IPACK %
GILLETTE MACH 3 CART 12 PACK %
CETAPHIL WASH SHAM 230 ML
x % GARNIER FRUCTIS SHAM 700 ML *
XGARNIER FRUCTIS SHAM %
SUDOCREAM GOGRAM %
FERRERO EGGS IOOGRAM %
FERRERO EGGS IOOGRAM
MARS KINDER LINDT 2 FOR$7
CREAMY YOGHURT 850 ML
x % SANPEl - LEGRINO MWATER ILITRE *
GOLD CHOICE CANOLA 0 4 LITRE
Total
for 14 items:
EFT
GST INCLUDED IN TOTAL
8.50
6.00
6.00
5.00
5.50
5 50
-
$4 .00
2, 50
1.52
9.00
$122 .92
$122 .92
$10 - 36
24 / 02 / 18 12: 04
0553
CREDIT ACCOUNT
APSN 0000 ATC 0590
PURCHASE
RRN 001210950000
AUTH 304336
WA AU
65696971
BKB40C1
MASTERCARD
Bankwest Credit
A0000000041010
AUD$ 122992
(00) APPROVED *
z;
Specials
X = Taxable items
Total Savings
$39 .18, "ErrorMessage": "",
"ErrorDetails": ""
},
],
"OCRExitCode": "1",
"IsErroredOnProcessing": "false",
"ErrorMessage": "null",
"ErrorDetails": "null",
"ProcessingTimeInMilliseconds": "7.042",
"SearchablePDFURL": "Searchable PDF not generated as it was not requested."
}
我想通过: -
json
请帮助我如何将此{
"data": "my json"
}
作为任何键的值传递给我。我试图将这个json传递给:
Expected ',' insted of 'L'
但在邮递员里面我收到了错误transferUserInfo
。请帮我。提前谢谢。
答案 0 :(得分:0)
您可以使用to_json
json
添加require 'json'
然后将数据发送为,
{
"data": yourhash.to_json
}