Showing posts with label Json. Show all posts
Showing posts with label Json. Show all posts

Monday, 6 June 2022

Python read json data from API

import pandas as pd

import requests


d = requests.get("https://www.yourwebsite.com/controller?ApiKey=value").json()
df = pd.DataFrame.from_dict(d['records'])
df.shape

Sunday, 10 May 2015

CSharp Read Resource File as Json

protected void Page_Load(object sender, EventArgs e)
        {
          mapResFileName = "MapResources.en-US.resx";
            if (m_UserLanguage == "ar")
            {
                mapResFileName = "MapResources.resx";
            }
            ClientScript.RegisterStartupScript(this.GetType(), "localizedString", getReourseFileAsJSON(mapResFileName), true);
        }





        public string getReourseFileAsJSON(String resourceFileName)
        {           
            try
            {
                string mapResString = "localizedString={'userLang':'" + m_UserLanguage + "',";
                ResXResourceReader rsxr = new ResXResourceReader(
                String.Format("{0}{1}\\{2}", System.AppDomain.CurrentDomain.BaseDirectory.ToString(), "App_GlobalResources", resourceFileName));
                foreach (DictionaryEntry d in rsxr)
                {
                    mapResString += "'" + d.Key.ToString() + "':'" + d.Value.ToString() + "',";
                }
                mapResString += "};";
                return mapResString;
            }
            catch (Exception exc)
            {
                return "File Not Found";
            }
            

        }