afsina
afsina

Reputation: 132

What is the best way of loading structured text resource file in Dart

I have a structured data file. I create the file so format can be flexible. For now it is a custom text format but it can be xml or Json as well. My intention is to load it all in Client side and then put it to an internal memory structure. What is the correct way of getting a resource file from server and parse in Dart?

Upvotes: 0

Views: 349

Answers (1)

Kai Sellgren
Kai Sellgren

Reputation: 30292

Have you considered using just JSON?

Do this on the server:

import 'dart:json';

var obj = {'foo': 'bar'};
var output = JSON.stringify(obj); // Send the output to the client.

then on the client you do:

import 'dart:json';

var obj = JSON.parse(jsonedObject); // obj now holds a {'foo': 'bar'}

Or did I understood the question wrong?

Upvotes: 2

Related Questions