1.Read die Rohdaten von data.txt
dies die Beispieldaten aus Textdatei istLesen Sie die Rohdaten aus Textdatei und dann wandeln sie in erwartet json-Format mit jquery
nike sport shirt 85 20<br>
nike sneeker 120 15<br>
nike pants 90 20<br>
spring field short 50 40<br>
spring field dress 78 50<br>
spring field bags 48 10<br>
adidas boost shoes 65 10<br>
adidas trainer 48 10<br>
adidas jacket 140 35<br>
H&M sweaters 49 15<br>
H&M swimwear 88 30<br>
H&M modern classics 200 5<br>
2.Convert sie in erwartetem json
Format
/* expected json format */
{
'nike': [
{ catagory: 'sport shirt', price: 85, quantity: 20 },
{ catagory: 'sneeker', price: 120, quantity: 15 },
{ catagory: 'pants', price: 90, quantity: 20 }
],
'spring field': [
{ catagory: 'short', price: 50, quantity: 40 },
{ catagory: 'dress', price: 78, quantity: 50 },
{ catagory: 'bag', price: 48, quantity: 10 }
],
'adidas': [
{ catagory: 'boost shoes', price: 65, quantity: 10 },
{ catagory: 'trainer', price: 48, quantity: 20 },
{ catagory: 'jacket', price: 140, quantity: 35 }
],
'H&M':[
{ catagory: 'sweaters', price: 49, quantity: 15 },
{ catagory: 'swimwear', price: 88, quantity: 30 },
{ catagory: 'modern classics', price: 200, quantity: 5 }
]
}
So, wie die Rohdaten aus Textdatei zu lesen und sie dann in ex umwandeln erkannt json Format mit jquery?
Dank
vorschlagen ' "spring field"„Würde Einstellung 'auf' Springfield "' oder '" spring_field "'; ähnlich mit "Boost Schuhe" und "moderne Klassiker", um die gleiche Anzahl von Wörtern pro Zeile zu haben – guest271314