Jump to content

CITY JSON API a bit sad - data there twice and HTML code


martbhell
 Share

Recommended Posts

Hi!

 

Seems some debug output or some such is included in the city api?

 

// mart

 

{"cityid":"20268","url":"https:\/\/politicsandwar.com\/city\/id=20268","nationid":"10065","name":"Truro","nation":"Nova Scotia","leader":"Chappie Tetravalal","continent":"North America","founded":"2015-01-27","age":345,"powered":"Yes","infrastructure":"2000.00","land":"2000.00","population":223000,"popdensity":111.5,"crime":0,"disease":0,"commerce":100,"avgincome":5.613,"pollution":0,"nuclearpollution":0,"basepop":200000,"basepopdensity":99.999950000025,"minimumwage":1.8709677419355,"poplostdisease":0,"poplostcrime":0,"coalpower":"0","oilpower":"0","nuclearpower":"1","windpower":"0","coalmine":"2","oilwell":"0","ironmine":"2","bauxitemine":"0","leadmine":"0","uraniummine":"1","farm":"0","oilrefinery":"1","steelmill":"3","aluminumrefinery":"1","munitionsfactory":"0","policestation":"1","hospital":"2","recyclingcenter":"2","subway":"1","supermarket":"0","bank":"3","shoppingmall":"3","stadium":"2","barracks":"5","factory":"5","airforcebase":"5","drydock":"0"}<!--

{

    "kind": "city",

    "data": {

        "citydata": {

            "cityid": 20268,

            "url": "https://politicsandwar.com/city/id=20268",

            "nationid": 10065,

            "name": "Truro",

            "nation": "Nova Scotia",

            "leader": "Chappie Tetravalal",

            "continent": "North America",

            "founded": "2015-01-27",

            "age": "345 days"

  },

  "stats": {

   "powered": "Yes",

   "infrastructure": 2000.00,

   "land": 2000.00,

   "population": 223000,

   "popdensity": 111.5,

   "crime": 0,

   "disease": 0,

   "commerce": 100,

   "avgincome": 5.613,

   "pollution": 0,

   "nuclearpollution": 0  },

  "improvements": {

   "power": {

    "coalpower": 0,

    "oilpower": 0,

    "nuclearpower": 1,

    "windpower": 0   },

   "resources": {

    "coalmine": 2,

    "oilwell": 0,

    "ironmine": 2,

    "bauxitemine": 0,

    "leadmine": 0,

    "uraniummine": 1,

    "farm": 0   },

   "manufacturing": {

    "oilrefinery": 1,

    "steelmill": 3,

    "aluminumrefinery": 1,

    "munitionsfactory": 0   },

   "civil": {

    "policestation": 1,

    "hospital": 2,

    "recyclingcenter": 2,

    "subway": 1   },

   "commerce": {

    "supermarket": 0,

    "bank": 3,

    "shoppingmall": 3,

    "stadium": 2   },

   "military": {

    "barracks": 5,

    "factory": 5,

    "airforcebase": 5,

    "drydock": 0   }

  },

  "cityfactors": {

   "basepop": 200000,

   "basepopdensity": 99.999950000025,

   "minimumwage": 1.8709677419355,

   "poplostdisease": 0,

   "poplostcrime": 0  }

}

}

-->

Edited by martbhell
  • Upvote 1
Link to comment
Share on other sites

Related to this, the city API no longer matches the other APIs.

 

{
"cityid": "23583",
"url": "https:\/\/politicsandwar.com\/city\/id=23583",
"nationid": "14511",
"name": "Mauritius",
"nation": "The Lost Isles",
"leader": "Shakyr",
"continent": "Australia",
"founded": "2015-03-09",
"age": 305,
"powered": "Yes",
"infrastructure": "1500.00",
"land": "2000.00",
"population": 165250,
"popdensity": 82.63,
"crime": 0,
"disease": 0,
"commerce": 100,
"avgincome": 4.665,
"pollution": 0,
"nuclearpollution": 0,
"basepop": 150000,
"basepopdensity": 74.999962500019,
"minimumwage": 1.5549597855228,
"poplostdisease": 0,
"poplostcrime": 0,
"coalpower": "0",
"oilpower": "0",
"nuclearpower": "1",
"windpower": "0",
"coalmine": "0",
"oilwell": "0",
"ironmine": "0",
"bauxitemine": "3",
"leadmine": "0",
"uraniummine": "0",
"farm": "5",
"oilrefinery": "0",
"steelmill": "0",
"aluminumrefinery": "3",
"munitionsfactory": "0",
"policestation": "1",
"hospital": "1",
"recyclingcenter": "1",
"subway": "1",
"supermarket": "0",
"bank": "3",
"shoppingmall": "3",
"stadium": "2",
"barracks": "2",
"factory": "1",
"airforcebase": "3",
"drydock": "0"
}
Instead of before, where it had.

{
    "kind": "city",
    "data": {
        "citydata": {
            ...
        }
        "stats": {
            ...
        }
    }
}
Just want to check that this is how the city API will be from now on, before I go and spend a few hours rewriting how I handle the city API (and add exceptions because it's different to the others).

sig_cybernations.PNG.8d49a01423f488a0f1b846927f5acc7e.PNG

Link to comment
Share on other sites

On top of Shakyr's question, is the alliance and nation format going to change too? I much prefer it the new way :P (luckily for me it should only take 5 mins to update everything)

Edited by Yosodog

[22:37:51] <&Yosodog> Problem is, everyone is too busy deciding which top gun character they are that no decision has been made

 

BK in a nutshell

Link to comment
Share on other sites

  • Administrators

I'll probably just move everything to the new way. I'm in the process of re-doing the APIs in a more proper way.

  • Upvote 2

Is there a bug? Report It | Not understanding game mechanics? Ask About It | Got a good idea? Suggest It

Forums Rules | Game Link

Link to comment
Share on other sites

I'll probably just move everything to the new way. I'm in the process of re-doing the APIs in a more proper way.

I've been meaning to complain about how data.alliancedata/nationdata/citydata was stupid. Also your bad formatting with random indentations (or lack thereof) all over the place.

RollSheepy.png

Link to comment
Share on other sites

  • Administrators

I've been meaning to complain about how data.alliancedata/nationdata/citydata was stupid. Also your bad formatting with random indentations (or lack thereof) all over the place.

 

The random indentations were not visible in the code itself. For whatever reason it was just getting rendered that way by the browser (honestly not sure why.)

Is there a bug? Report It | Not understanding game mechanics? Ask About It | Got a good idea? Suggest It

Forums Rules | Game Link

Link to comment
Share on other sites

The random indentations were not visible in the code itself. For whatever reason it was just getting rendered that way by the browser (honestly not sure why.)

If you're using PHP, compile it all in an array and then use the following, to get it to display nicely.

$json_string = json_encode($data, JSON_PRETTY_PRINT);

sig_cybernations.PNG.8d49a01423f488a0f1b846927f5acc7e.PNG

Link to comment
Share on other sites

  • Administrators

If you're using PHP, compile it all in an array and then use the following, to get it to display nicely.

$json_string = json_encode($data, JSON_PRETTY_PRINT);

 

I know, this is what I've switched to, and how the API runs now (just without pretty print.) Previously though, I just had it all formatted with the correct levels of indentation in the file, and the browser simply rendered it with random indentations that I can't explain.

Is there a bug? Report It | Not understanding game mechanics? Ask About It | Got a good idea? Suggest It

Forums Rules | Game Link

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and the Guidelines of the game and community.