Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] java – How to fix file .json not found

Posted on November 14, 2022

Solution 1 :

Looks like the problem is how you are trying to access your json. I’m not sure(because it doesn’t say) as to where are you storing it, but here the docs explain a smooth explanation as to how access stored files in a mobile phone using Xamarin Forms

Solution 2 :

You want to read from ‘DATA.json’ but gave the path ‘File.json’.

Problem :

I am trying here to consume the data from a JSON file:

DATA.json

[

{"Label"
        
        :"USA",
        "Adress":"This is the us",
        "Lat":"36.9628066",
        "Lng":"-122.0194722"
},
{ "Label"  :"USA",
         "Address":"2020",
          "Lat":"36.9628066", 
          "Lng":"-122.0194722" }

]

Then applying it in my Mainclass:

using System.Collections.Generic;
using Xamarin.Forms.Maps;
using Xamarin.Forms;
using System.IO;
using Newtonsoft.Json;
using System;


namespace Orbage
{
    

class MapPage : ContentPage
    {
        public MapPage()
        {
            CustomMap customMap = new CustomMap
            {
                MapType = MapType.Street

            };
            // ...
            Content = customMap;

            var json = File.ReadAllText("File.json");
            var places = JsonConvert.DeserializeObject<List<File>>(json);
            foreach (var place in places)
            {
                CustomPin pin = new CustomPin
                {
                    Type = PinType.Place,
                    Position = new Position(Double.Parse(place.Lat), Double.Parse(place.Lng)),
                    Label = place.Label,
                    Address = place.Address,
                    Name = "Xamarin",

                    Url = "http://xamarin.com/about/"
                };



                customMap.CustomPins = new List<CustomPin> { pin };

                customMap.Pins.Add(pin);
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(37.79752, -122.40183), Distance.FromMiles(1.0)));
            }
        }
    }


}

But when I put the file in there it says that it doesn’t exist.

Error:

FilenotfoundException

Whats the fix for this.

I tried:

  • Changing the location of the file.
  • Its name
    = Instead of E:/-/- I even wrote file.json but I still get the same error.

Comments

Comment posted by ItsRaptorman

Please help me!

Comment posted by ItsRaptorman

@Jason the error is not coming now but the marker isn’t showing

Comment posted by Jason

changing the question you asked completely invalidates the answer that I gave you. Please don’t do that.

Comment posted by ItsRaptorman

oops sorry I din’t know that….. Please retype the answer and add this line MainPage = new Orbage.MapPage(); Because that was the fix and the using forms.

READ  [ANSWERED] android - Start any application through termux command line for example chrome, youtube and some other application like cryptotabbrowser
Powered by Inline Related Posts

Comment posted by Jason

where is your custom renderer?

Comment posted by ItsRaptorman

Thanks for answering.

Comment posted by ItsRaptorman

No, That was only for the answerer to understand what I wrote there.. Thanks for writing the answer!

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress