#1 Re: mORMot 1 » JSON parsing problem » 2016-11-19 22:39:13

This is it!!

Thank you very much.

#2 Re: mORMot 1 » JSON parsing problem » 2016-11-19 12:58:11

Thanks for the answer.

I'm sorry I don't understand the question (I'm playing with JSON and Mormot for the first time). My objective is to get distance and duration values from this Json string I provided. Maybe I'm supposed to answer "First position".

I would like to get distance = 3822.4 and duration = 264.6

I'm trying to use TDocVariantData like in the mORMot documentation because I really like the way it is done (smart and simple without using class or record definition and blazing fast).

From your answer I understand it cannot work without giving the position of the item inside the array. How to do it?

#3 mORMot 1 » JSON parsing problem » 2016-11-19 07:55:14

Bibo
Replies: 6

Hi,

I'm doing this:


const
  __MyJSON ='{"waypoints":[{"location":[14.723485,-17.443965],"name":"C46","hint":"m88zgO2Ev4BsywcAtAkAAEQBAACiCAAAXUoAANkSIADlBQAAnangAIPT9f5RnOAAqnT1_gQAAQHOiWch"},' +
            '{"location":[14.759195,-17.448485],"name":"C46","hint":"m88zgO2Ev4BsywcAvgMAAF8CAADuGAAA7D4AANkSIADlBQAAGzXhANvB9f6GOOEAz9r1_gcAAQHOiWch"}],' +
            '"routes":[{"distance":3822.4,"duration":264.6,"legs":[{"distance":3822.4,"duration":264.6,"summary":"","steps":[]}],"geometry":"x_niBytzxAf[e~E"}],"code":"Ok"}';


procedure TForm1.btnParseClick(Sender: TObject);
    var doc : Variant;
    R:Double;
begin
  doc := _JsonFast(__MyJSON);
  R := TDocVariantData(doc).GetValueByPath(['routes','duration']);
end;


Result(R) is 0.
How can I get duration value?
Thanks.

Board footer

Powered by FluxBB